mikebrady / shairport-sync-docker

Docker setup for Shairport Sync
MIT License
49 stars 19 forks source link

Trying to setup shairport docker to start at boot using systemd #5

Closed yeralin closed 3 years ago

yeralin commented 3 years ago

Hi,

System: Linux raspberrypi 5.4.72-v7+ #1356 SMP Thu Oct 22 13:56:54 BST 2020 armv7l GNU/Linux

The docker image is running perfectly on my raspberry. Now I wanted to start it at boot, here is my systemd service file:

[Unit]
Description=Shairport Container
After=docker.service
After=avahi-daemon.service
Requires=docker.service
Requires=avahi-daemon.service

[Service]
User=<uid>
Group=<gid>
Restart=always
ExecStartPre=-/usr/bin/docker stop shairport
ExecStart=/usr/bin/docker start -a shairport
ExecStop=/usr/bin/docker stop shairport

[Install]
WantedBy=multi-user.target

But after reboot, I get Process 12 died: No such process; trying to remove PID file. (/run/avahi-daemon//pid) in shairport docker logs. The only way to fix it is to docker restart shairport.

mikebrady commented 3 years ago

Thanks for the post. I don't think that is how you set a docker image to start on boot -- see the Readme at https://hub.docker.com/repository/docker/mikebrady/shairport-sync.

yeralin commented 3 years ago

Right, that service is for starting the existing docker image at boot. The original command was:

docker run -d \
--restart unless-stopped \
--name shairport \
--net host \
--device /dev/snd \
mikebrady/shairport-sync -- \
-d hw:1
mikebrady commented 3 years ago

Thanks. That command should, in fact, cause the existing image to be launched automatically on boot. It does for me.

yeralin commented 3 years ago

Right, but when I reboot my raspberry, I get Process 12 died: No such process; trying to remove PID file. (/run/avahi-daemon//pid), and I have to execute systemctl restart shairport

Seems like it gets launched too early at boot, and something is not up yet for it to work properly.

But then I have After=avahi-daemon.service

mikebrady commented 3 years ago

Just circling back to this. You don't need to do anything at all to the host machine's systemd service file to get Docker to start the image after boot. If you have made changes to the systemd service file, then I'd suggest you undo them.