Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to start after mpd on boot #11

Closed
petronny opened this issue May 12, 2016 · 8 comments
Closed

Fail to start after mpd on boot #11

petronny opened this issue May 12, 2016 · 8 comments

Comments

@petronny
Copy link

Hi, I'm using Archlinux and have installed mpd and mpd-notification-git.
Then I want them both to run automatically on boot.

systemctl --user enable mpd
systemctl --user enable mpd-notification

But these command doesn't work. Here is the log of mpd-notification:

20:37:48 systemd[424]: Started MPD Notification.
20:37:48 mpd-notification[433]: /usr/bin/mpd-notification: Connection refused
20:37:48 systemd[424]: mpd-notification.service: Main process exited, code=exited, status=1/FAILURE
20:37:48 systemd[424]: mpd-notification.service: Unit entered failed state.
20:37:48 systemd[424]: mpd-notification.service: Failed with result 'exit-code'.

And the log of mpd:

20:37:48 systemd[424]: Started Music Player Daemon.
20:37:49 mpd[432]: May 12 20:37 : server_socket: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)

Then referring to Archlinux Wiki, I add both Requires=mpd.service and After=mpd.service to the [Unit] section of mpd-notification.service. But mpd-notification still start before mpd opening its port.
Maybe we need a script to delay a few seconds.

@eworm-de
Copy link
Owner

Just pushed 11b436d to branch systemd.
Not sure if it changes anything for you, though. Want to give it a try?

When did this start to break? Did it work reliable before?

@petronny
Copy link
Author

Thank you but I still get Connection refused after updated to 11b436d .
My workaround is create a script to delay 3 seconds, then run mpd-notification.

#!/bin/sh
sleep 3
/usr/bin/mpd-notification
After=mpd.service
...
ExecStart=/somewhere/to/the/script.sh

Of course it is a little ugly...
How about creating a loop to connect to the server every period time in mpd-notification.c?

@eworm-de
Copy link
Owner

Forced sleep times and connecting in loop are really ugly workarounds. Usually systemd should get this right, otherwise the software (mpd in this case) is broken.

Let's try something different. Could you please edit /usr/lib/systemd/user/mpd.service and add a line

Type=forking

and change the ExecStart= line to

ExecStart=/usr/bin/mpd

The complete file should look something like this:

[Unit]
Description=Music Player Daemon
After=network.target sound.target

[Service]
Type=forking
ExecStart=/usr/bin/mpd

# allow MPD to use real-time priority 50
LimitRTPRIO=50
LimitRTTIME=infinity

[Install]
WantedBy=default.target

@eworm-de
Copy link
Owner

Or you could try with

Type=notify

as committed upstream: systemd: set Type=notify

@eworm-de
Copy link
Owner

Ah, this will not (yet) work... It needs another commit at compile time: Main: notify systemd when MPD is ready

@eworm-de
Copy link
Owner

Ok, let's use a workaround until real fixes linked above make its way into a release.
Can you try branch systemd with 67c75e3?

@eworm-de
Copy link
Owner

eworm-de commented Oct 4, 2016

Closed with 67c75e3.

@eworm-de eworm-de closed this as completed Oct 4, 2016
@eworm-de
Copy link
Owner

eworm-de commented Jan 4, 2017

I reverted this in master, should just work with mpd version 0.20 now. Can you give it a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants