1 #pragma once
2 
3 #include "config.h"
4 
5 #include <sdbusplus/bus.hpp>
6 
7 namespace phosphor
8 {
9 namespace rsyslog_utils
10 {
11 
12 /** @brief Restart rsyslog's systemd unit
13  *         Ensures that it is restarted even if the start limit was
14  *         hit in systemd.
15  */
16 void restart()
17 {
18     auto bus = sdbusplus::bus::new_default();
19     constexpr char service[] = "rsyslog.service";
20 
21     {
22         auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
23                                           SYSTEMD_INTERFACE, "ResetFailedUnit");
24         method.append(service);
25         bus.call_noreply(method);
26     }
27 
28     {
29         auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
30                                           SYSTEMD_INTERFACE, "RestartUnit");
31         method.append(service, "replace");
32         bus.call_noreply(method);
33     }
34 }
35 
36 } // namespace rsyslog_utils
37 } // namespace phosphor
38