summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-04-01 15:50:43 -0700
committerWilliam A. Kennington III <wak@google.com>2019-04-01 15:53:52 -0700
commitbc89289f48ce5e1c8e5c66e657a176a0cd881d39 (patch)
tree42971c0fd75f7742e0d8bbb4e658fc8cbdaca5a8
parent8024d1dc7dfff6360f3e1bdbce145652eb5698be (diff)
downloadphosphor-logging-bc89289f48ce5e1c8e5c66e657a176a0cd881d39.zip
phosphor-logging-bc89289f48ce5e1c8e5c66e657a176a0cd881d39.tar.gz
utils: restart: Always restart service
If the service has hit its reset limit in systemd, calling RestartUnit on the service will do nothing. This ensures that the service will try and restart at least once after a configuration change, regardless of whether or not it has failed in the past. Change-Id: I28962fc4ef9da641d1d19b8e09450e40d76e9c27 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--phosphor-rsyslog-config/utils.hpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/phosphor-rsyslog-config/utils.hpp b/phosphor-rsyslog-config/utils.hpp
index 017a439..30799cd 100644
--- a/phosphor-rsyslog-config/utils.hpp
+++ b/phosphor-rsyslog-config/utils.hpp
@@ -10,14 +10,27 @@ namespace rsyslog_utils
{
/** @brief Restart rsyslog's systemd unit
+ * Ensures that it is restarted even if the start limit was
+ * hit in systemd.
*/
void restart()
{
auto bus = sdbusplus::bus::new_default();
- auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "RestartUnit");
- method.append("rsyslog.service", "replace");
- bus.call_noreply(method);
+ constexpr char service[] = "rsyslog.service";
+
+ {
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "ResetFailedUnit");
+ method.append(service);
+ bus.call_noreply(method);
+ }
+
+ {
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "RestartUnit");
+ method.append(service);
+ bus.call_noreply(method);
+ }
}
} // namespace rsyslog_utils
OpenPOWER on IntegriCloud