From 7b575f61d0f5c34267fcfd60229d25edbcbe33da Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Sat, 21 Mar 2015 14:18:15 +0100
Subject: [PATCH] Main: notify systemd when MPD is ready

---
 src/Main.cxx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/Main.cxx b/src/Main.cxx
index 9b7679369..713701e6e 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -106,6 +106,10 @@
 #include <glib.h>
 #endif
 
+#ifdef ENABLE_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
 #include <stdlib.h>
 
 #ifdef HAVE_LOCALE_H
@@ -662,6 +666,10 @@ static int mpd_main_after_fork(struct options options)
 	   a huge value to allow the kernel to reduce CPU wakeups */
 	SetThreadTimerSlackMS(100);
 
+#ifdef ENABLE_SYSTEMD_DAEMON
+	sd_notify(0, "READY=1");
+#endif
+
 	/* run the main loop */
 	instance->event_loop->Run();