blob: f5df8aee55acc3062e8c6e854991938e6e7dd265 [file] [log] [blame]
Deepak Kodihallic4966192018-08-23 02:19:58 -05001#pragma once
2
3#include "config.h"
Patrick Venturef18bf832018-10-26 18:14:00 -07004
Deepak Kodihallic4966192018-08-23 02:19:58 -05005#include <sdbusplus/bus.hpp>
6
7namespace phosphor
8{
9namespace rsyslog_utils
10{
11
12/** @brief Restart rsyslog's systemd unit
William A. Kennington IIIbc892892019-04-01 15:50:43 -070013 * Ensures that it is restarted even if the start limit was
14 * hit in systemd.
Deepak Kodihallic4966192018-08-23 02:19:58 -050015 */
16void restart()
17{
18 auto bus = sdbusplus::bus::new_default();
William A. Kennington IIIbc892892019-04-01 15:50:43 -070019 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");
William A. Kennington IIIe5e3a9c2019-04-03 11:13:09 -070031 method.append(service, "replace");
William A. Kennington IIIbc892892019-04-01 15:50:43 -070032 bus.call_noreply(method);
33 }
Deepak Kodihallic4966192018-08-23 02:19:58 -050034}
35
36} // namespace rsyslog_utils
37} // namespace phosphor