mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.29k stars 574 forks source link

Auto start after reboot #179

Closed maumi closed 8 years ago

maumi commented 8 years ago

I use shairport-sync on 2 rPi2, both with OSMC. Ithink I did the same things to install it. On one pi ss starts automatic but on the other pi I always need to "sudo systemctl start shairport-sync". I know it's not a real issue related to ss, more to debian. But maybe you have an idea to solve this little annoying problem.

mikebrady commented 8 years ago

On the machine where it does not start automatically, enter sudo systemctl enable shairport-sync and then it should start automatically on reboot.

maumi commented 8 years ago

Already tried that. But no effect. I think it' something preventing to start it at an early stage of system start. Even tried to put systemctl start in rc.local but didn't changed a thing. But when typing manual systemctl start it always works. Are there any logs where I could see the reason for this behavior?

mikebrady commented 8 years ago

Thanks. Is AirPlay disabled in Kodi?

Look in the log using journalctl as root. Also set log verbosity in Shairport Sync to 1 and restart.

maumi commented 8 years ago

Sorry, I've said wrong things. The system where it works on startup is a cubox with pure debian, so no kodi distro. Back to the problem: Airplay on Kodi is disabled. Log with verbosity 1 looks unspectacular. Even with verb. 3 I can't see any errors.

Dez 17 10:13:49 osmc shairport-sync[263]: Output device name is "default". Dez 17 10:13:49 osmc shairport-sync[263]: startup Dez 17 10:13:49 osmc shairport-sync[263]: avahi: avahi_register. Dez 17 10:13:49 osmc shairport-sync[263]: avahi: register_service. Dez 17 10:13:49 osmc shairport-sync[263]: Avahi without metadata

Ah ok, grep found more than my eyes.

End of log:

Dez 17 10:17:33 osmc shairport-sync[254]: avahi: avahi_register. Dez 17 10:17:33 osmc shairport-sync[254]: avahi: register_service. Dez 17 10:17:33 osmc shairport-sync[254]: Avahi without metadata Dez 17 10:17:43 osmc systemd[1]: shairport-sync.service: main process exited, code=killed, status=6/ABRT Dez 17 10:17:43 osmc systemd[1]: Unit shairport-sync.service entered failed state. Dez 17 10:17:43 osmc shairport-sync[254]: avahi client failure Dez 17 10:17:43 osmc shairport-sync[254]: avahi: avahi_unregister. Dez 17 10:17:43 osmc shairport-sync[254]: shairport-sync: thread-watch.c:149: avahi_threaded_poll_stop: Assertion `!pthread_equal(pthread_self(), p->thread_id)' failed.

mikebrady commented 8 years ago

That's interesting – it looks as if avahi isn't ready, or something similar.

The only thing I can suggest is to delay starting Shairport Sync for a few seconds – maybe this might be relevant http://www.freedesktop.org/software/systemd/man/systemd.timer.html

maumi commented 8 years ago

Great. Created a delay of 10s. Normally I never restart my pi so I don't experiment on smaller timer. Thanks for your fast and good support. I really like your project and enjoy how flawless it works. Even with multi room sync and also with iOS 9.

mikebrady commented 8 years ago

Thanks. If you used that systemd timer mechanism, would you be kind enough to post the file contents?

maumi commented 8 years ago

For sure. File is next to shairport-sync.service and called shairport-sync.timer

[Unit]
Description=Shairport Sync AirTunes receiver

[Timer]                       
OnBootSec=10s              
Unit=shairport-sync.service

[Install]    
WantedBy=multi-user.target  

Then you need to disable shairport-sync service because the timer is calling the service.

systemctl disable shairport-sync
systemctl start shairport-sync.timer
systemctl enable shairport-sync.timer

[Edit: just corrected the names used above.]

mikebrady commented 8 years ago

Fantastic, thanks!