[Solved] Auto MPD Restart?

Hi,

I would like to know if there is a way that the process of restarting the MPD using “/etc/init.d/mpd restart” can be automated at every startup.

I used to go the through a routine of just powering off the Voumio/Pi at the plug and then the next time I would go to use the device it would not play music, I then found that by using the above script it seemed to rectify this problem, however expecting my wife to log on using SSH and do this is not a good idea. I now always use the “Power Off” via the web interface before pulling the power to the Pi, however I was thinking more in case of power failure of just ever forgetting to follow my normal routine - it would certainly help the next time I came to use the device.

Is there any reason why this couldn’t be run once automatically after all the other PI’s functions are running to ensure a clean slate every time?

I hope I have explained myself.

Thanks.

Andy.

Hi,
I think an entry in /etc/rc.local could do what you want:

sudo nano /etc/rc.local

at the end of the file:

sudo /etc/init.d/mpd restart &

tobbes

Many thanks for the reply.

I will give this a whirl and see how I get on.

Many thanks.

Andrew.

Hi Guys,

I’ve got a similar problem, when the power went down last night and now i can’t get into the web interface.

I’ve tried to add sudo /etc/init.d/mpd restart & to the rc.local above the exit 0 line to prevent it from happening again.

but this doesn’t seem give me acces to the web interface.

when I ssh into the R-Pi, and execute /etc/init.d/mpd restart I get the following error: [ ok ] Stopping Music Player Daemon: mpd. [....] Starting Music Player Daemon: mpdfailed to open log file "/var/log/mpd/mpd.log" (config line 11): Permission denied failed!

is there any other way to fix the web interface?

edit

seems I had to login as root… to execute “mpd restart”

so i checked again what would happen if I just pulled the power. It broke the web interface again. is there another wat to execute “mod restart” on boot?

edit 2

it seems to work now:

removed the “sudo” so I added:

/etc/init.d/mpd restart &

to “rc.local”

Good work, anyway I’m trying to implement a solution that looks to mpd status, and if it bricks it will restart by its own…

hi michelangelo,

could you check if this is a possible solution to implement?
since the worker process is a loop, this line will check if mpc can access mpd, if not it will restart mpd
http://volumio.org/forum/volumio-can-not-reconnect-after-few-hours-t797-10.html#p3461