From 11b436d32299c71cc0828faff66c66a921842a05 Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail@eworm.de>
Date: Thu, 12 May 2016 23:43:29 +0200
Subject: try to get systemd unit start order right

---
 systemd/mpd-notification.service | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'systemd')

diff --git a/systemd/mpd-notification.service b/systemd/mpd-notification.service
index c377c90..2e907df 100644
--- a/systemd/mpd-notification.service
+++ b/systemd/mpd-notification.service
@@ -1,6 +1,11 @@
 [Unit]
 Description=MPD Notification
-Requires=mpd.service
+# Do not require any service here! We do rely on mpd OR network (for
+# a remote mpd instance). So let the user care.
+# We want to order after, though. This makes sure the resource is
+# available on start and mpd-notification can cleanly disconnect on
+# system shutdown.
+After=mpd.service network.target network-online.target
 
 [Service]
 Type=simple
-- 
cgit v1.2.3


From 67c75e3155104e7208171be8c5bac5d01fcb063f Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail@eworm.de>
Date: Mon, 16 May 2016 22:10:31 +0200
Subject: work around mpd initialization issue

---
 systemd/mpd-notification.service | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'systemd')

diff --git a/systemd/mpd-notification.service b/systemd/mpd-notification.service
index 2e907df..ab9e265 100644
--- a/systemd/mpd-notification.service
+++ b/systemd/mpd-notification.service
@@ -9,6 +9,13 @@ After=mpd.service network.target network-online.target
 
 [Service]
 Type=simple
+# Using mpd user service can result in mpd-notification starting too early
+# as systemd thinks mpd has finished initialization but socket is not yet
+# available. So sleep for a second before starting.
+# TODO: Remove workarount when upstream fix is released. Currently in git:
+# http://git.musicpd.org/cgit/master/mpd.git/commit/?id=7b575f61
+# http://git.musicpd.org/cgit/master/mpd.git/commit/?id=c85ba733
+ExecStartPre=/usr/bin/sleep 1
 ExecStart=/usr/bin/mpd-notification
 
 [Install]
-- 
cgit v1.2.3