Search code examples
linuxserviceraspberry-pipidstart-stop-daemon

Could not stop mpd service (No /usr/bin/mpd found running; none killed)


Whenever I want to stop my mpd server running in my RaspBMC by typing:

service mpd stop

The console shows the typical [ ok ] message:

[ ok ] Stopping Music Player Daemon: mpd.

But the service doesn't really stops at all (the process keeps running). I've made a deep search in the service script and found the call to start-stop-daemon:

start-stop-daemon --stop --quiet --oknodo --retry 5 --pidfile ~/.mpd/pid --exec /usr/bin/mpd

If I execute this command in a console (without the --quiet option) I get the following message:

No /usr/bin/mpd found running; none killed.

But the process is really running. I've checked both the pid file and exec file (/usr/bin/mpd) and they are correct. I noticed this error disappears when running the command as superuser (with sudo), so it seems to be a permissions issue, but I don't really understand why the /etc/init.d/mpd script is not capable of detecting the process being run... it's always called with sudo, so it should not have permission issues, shouldn't?

What's wrong with this configuration? What should I change to make the service stop correctly using the service command?


Solution

  • I finally found it! The problem is the path specified for the pid file in the mpd.conf is

    pid_file "~/.mpd/pid"

    This seems not to work properly when stopping it from service command. For the moment I changed it for

    pid_file "/home/MyUserName/.mpd/pid"

    and works fine, but as soon as possible, I'll move it to /var/run/mpd/ as it seems to be the right place to be in.