From 997fb31d0ea066e34e9e6d93dbf6ded1aceaa25e Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Wed, 25 Jan 2023 15:18:16 +0100 Subject: [PATCH] Use systemd state RELOADING when ip address changed In systemd when entering state STOPPING, you can't go back to READY. So, we check if we're supposed to stop or just restart, and tells that to systemd. --- daemon/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 6e7dcba..aa24561 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -216,8 +216,13 @@ int main(int argc, char* argv[]) { std::this_thread::sleep_for(std::chrono::seconds(1)); } #ifdef _USE_SYSTEMD_ - sd_notify(0, "STOPPING=1"); - sd_notify(0, "STATUS=Stopping"); + if (is_terminated()) { + sd_notify(0, "STOPPING=1"); + sd_notify(0, "STATUS=Stopping"); + } else { + sd_notify(0, "RELOADING=1"); + sd_notify(0, "STATUS=Restarting"); + } #endif /* save session status to file */