Deepak Kodihalli | c496619 | 2018-08-23 02:19:58 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "config.h" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 4 | |
Deepak Kodihalli | c496619 | 2018-08-23 02:19:58 -0500 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
| 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace rsyslog_utils |
| 10 | { |
| 11 | |
| 12 | /** @brief Restart rsyslog's systemd unit |
William A. Kennington III | bc89289 | 2019-04-01 15:50:43 -0700 | [diff] [blame] | 13 | * Ensures that it is restarted even if the start limit was |
| 14 | * hit in systemd. |
Deepak Kodihalli | c496619 | 2018-08-23 02:19:58 -0500 | [diff] [blame] | 15 | */ |
| 16 | void restart() |
| 17 | { |
| 18 | auto bus = sdbusplus::bus::new_default(); |
William A. Kennington III | bc89289 | 2019-04-01 15:50:43 -0700 | [diff] [blame] | 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"); |
William A. Kennington III | e5e3a9c | 2019-04-03 11:13:09 -0700 | [diff] [blame] | 31 | method.append(service, "replace"); |
William A. Kennington III | bc89289 | 2019-04-01 15:50:43 -0700 | [diff] [blame] | 32 | bus.call_noreply(method); |
| 33 | } |
Deepak Kodihalli | c496619 | 2018-08-23 02:19:58 -0500 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | } // namespace rsyslog_utils |
| 37 | } // namespace phosphor |