dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From af4ec4309e8f82aad87a8d574785c12f8763d5f8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 21 Aug 2014 17:19:28 +0200
Subject: [PATCH] notify: send STOPPING=1 from our daemons

---
 src/bus-proxyd/bus-proxyd.c         | 6 +++++-
 src/core/manager.c                  | 3 ++-
 src/initctl/initctl.c               | 1 +
 src/journal-remote/journal-remote.c | 6 ++++--
 src/journal-remote/journal-upload.c | 5 ++++-
 src/journal/journald.c              | 4 +++-
 src/login/logind.c                  | 1 +
 src/machine/machined.c              | 1 +
 src/network/networkd.c              | 1 +
 src/nspawn/nspawn.c                 | 8 +++++++-
 src/resolve/resolved.c              | 4 +++-
 src/shutdownd/shutdownd.c           | 1 +
 src/timesync/timesyncd.c            | 8 ++++++--
 13 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index d8d989b9b0..d35d7f63b2 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -239,7 +239,7 @@ static int rename_service(sd_bus *a, sd_bus *b) {
                   pid, p,
                   uid, name,
                   a->unique_name);
-                ;
+
         return 0;
 }
 
@@ -1474,6 +1474,10 @@ int main(int argc, char *argv[]) {
         }
 
 finish:
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Shutting down.");
+
         policy_free(&policy);
         strv_free(arg_configuration);
         free(arg_address);
diff --git a/src/core/manager.c b/src/core/manager.c
index c91ece116f..7401817844 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2551,7 +2551,8 @@ void manager_check_finished(Manager *m) {
         bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec);
 
         sd_notifyf(false,
-                   "READY=1\nSTATUS=Startup finished in %s.",
+                   "READY=1\n"
+                   "STATUS=Startup finished in %s.",
                    format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC));
 }
 
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index 0954e58afd..f1c2b8dfb4 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -431,6 +431,7 @@ int main(int argc, char *argv[]) {
 
 fail:
         sd_notify(false,
+                  "STOPPING=1\n"
                   "STATUS=Shutting down...");
 
         server_done(&server);
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 7f422bfb37..1cc86aeaf3 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -1530,10 +1530,12 @@ int main(int argc, char **argv) {
                 }
         }
 
-        server_destroy(&s);
+        sd_notifyf(false,
+                   "STOPPING=1\n"
+                   "STATUS=Shutting down after writing %" PRIu64 " entries...", s.event_count);
         log_info("Finishing after writing %" PRIu64 " entries", s.event_count);
 
-        sd_notify(false, "STATUS=Shutting down...");
+        server_destroy(&s);
 
         free(arg_key);
         free(arg_cert);
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index bdeeff6778..40c380aa9e 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -818,7 +818,10 @@ int main(int argc, char **argv) {
         }
 
 cleanup:
-        sd_notify(false, "STATUS=Shutting down...");
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Shutting down...");
+
         destroy_uploader(&u);
 
 finish:
diff --git a/src/journal/journald.c b/src/journal/journald.c
index b1a0e25d0c..de40827d6a 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -116,7 +116,9 @@ int main(int argc, char *argv[]) {
         server_driver_message(&server, SD_MESSAGE_JOURNAL_STOP, "Journal stopped");
 
 finish:
-        sd_notify(false, "STATUS=Shutting down...");
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Shutting down...");
 
         server_done(&server);
 
diff --git a/src/login/logind.c b/src/login/logind.c
index 006c56ae51..52e1c43a47 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1226,6 +1226,7 @@ int main(int argc, char *argv[]) {
 
 finish:
         sd_notify(false,
+                  "STOPPING=1\n"
                   "STATUS=Shutting down...");
 
         if (m)
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 6160320127..f9d180d24a 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -350,6 +350,7 @@ int main(int argc, char *argv[]) {
 
 finish:
         sd_notify(false,
+                  "STOPPING=1\n"
                   "STATUS=Shutting down...");
 
         if (m)
diff --git a/src/network/networkd.c b/src/network/networkd.c
index 665f4c4709..fdb80368d4 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -125,6 +125,7 @@ int main(int argc, char *argv[]) {
 
 out:
         sd_notify(false,
+                  "STOPPING=1\n"
                   "STATUS=Shutting down...");
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index d01da45930..2c718557ee 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3071,7 +3071,9 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        sd_notify(0, "READY=1");
+        sd_notify(false,
+                  "READY=1\n"
+                  "STATUS=Container running.");
 
         assert_se(sigemptyset(&mask) == 0);
         assert_se(sigemptyset(&mask_chld) == 0);
@@ -3504,6 +3506,10 @@ int main(int argc, char *argv[]) {
         }
 
 finish:
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Terminating...");
+
         loop_remove(loop_nr, &image_fd);
 
         if (pid > 0)
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index 8235558585..88c3bcc591 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -100,7 +100,9 @@ int main(int argc, char *argv[]) {
         sd_event_get_exit_code(m->event, &r);
 
 finish:
-        sd_notify(false, "STATUS=Shutting down...");
+        sd_notify(false,
+                  "STOPPIN=1\n"
+                  "STATUS=Shutting down...");
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index 92907497ed..99aa4b32b3 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -456,6 +456,7 @@ finish:
         }
 
         sd_notify(false,
+                  "STOPPING=\n"
                   "STATUS=Exiting...");
 
         return r;
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index 351bfd0236..ee3bc99ae0 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -132,7 +132,9 @@ int main(int argc, char *argv[]) {
                 log_warning("Failed to parse configuration file: %s", strerror(-r));
 
         log_debug("systemd-timesyncd running as pid %lu", (unsigned long) getpid());
-        sd_notify(false, "READY=1");
+        sd_notify(false,
+                  "READY=1\n"
+                  "STATUS=Daemon is running");
 
         if (network_is_online()) {
                 r = manager_connect(m);
@@ -153,7 +155,9 @@ int main(int argc, char *argv[]) {
         sd_event_get_exit_code(m->event, &r);
 
 finish:
-        sd_notify(false, "STATUS=Shutting down...");
+        sd_notify(false,
+                  "STOPPING=1\n"
+                  "STATUS=Shutting down...");
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }