daemon: Use Type=notify for systemd service
authorFelipe Sateler <fsateler@debian.org>
Thu, 13 Aug 2015 22:58:27 +0000 (19:58 -0300)
committerArun Raghavan <git@arunraghavan.net>
Fri, 25 Sep 2015 11:59:02 +0000 (17:29 +0530)
This ensures systemd knows when pulseaudio finishes loading, thus never
marking pulseaudio as active if startup fails.

src/daemon/main.c
src/daemon/systemd/user/pulseaudio.service.in

index 6f7be7a..c7b15e7 100644 (file)
@@ -1131,12 +1131,20 @@ int main(int argc, char *argv[]) {
 
     pa_log_info("Daemon startup complete.");
 
+#ifdef HAVE_SYSTEMD_DAEMON
+    sd_notify(0, "READY=1");
+#endif
+
     retval = 0;
     if (pa_mainloop_run(mainloop, &retval) < 0)
         goto finish;
 
     pa_log_info("Daemon shutdown initiated.");
 
+#ifdef HAVE_SYSTEMD_DAEMON
+    sd_notify(0, "STOPPING=1");
+#endif
+
 finish:
 #ifdef HAVE_DBUS
     if (server_bus)
index e08ff1e..df42fc3 100644 (file)
@@ -2,6 +2,8 @@
 Description=Sound Service
 
 [Service]
+# Note that notify will only work if --daemonize=no
+Type=notify
 ExecStart=@PA_BINARY@ --daemonize=no
 Restart=on-failure