Skip to content

Commit

Permalink
Add dependencies to the spotifyd systemd service
Browse files Browse the repository at this point in the history
Spotifyd crashes if it starts before either the sound card is configured or the network is available. Whilst this is not too bad, it causes a restart of the service when started at boot. It is nicer to just depend on the targets that systemd provides to signal availability of both.
  • Loading branch information
bertptrs authored Dec 12, 2018
1 parent 010b0ca commit 0c04c90
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/spotifyd.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/spotifyd --no-daemon
Expand Down

5 comments on commit 0c04c90

@tomty89
Copy link

@tomty89 tomty89 commented on 0c04c90 Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bertptrs Has this ever worked for you? As far as I can tell, those dependencies/ordering are not really valid for services of user contexts. I've been using ExecStartPre=/usr/lib/systemd/systemd-networkd-wait-online to actually avoid the restarting.

@bertptrs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but I do run it as a system service. Not as root, though.

@tomty89
Copy link

@tomty89 tomty89 commented on 0c04c90 Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but I do run it as a system service. Not as root, though.

That explains it. Feel like this should be reverted because upstream ships it as user service.

@bertptrs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree; this service is valid both as a user service and a system service.

Note: instead of your ExecStartPre trick, you should enable systemd-networkd-wait-online.service instead. This causes network-online.target to be reached only after an internet connection is actually established.

@tomty89
Copy link

@tomty89 tomty89 commented on 0c04c90 Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not shipped as a system service. If running it with system service is fine (even just in some case), then we can ship one with these deps/ordering additionally.

It has nothing to do with what I enables. The targets are entirely ignored/invalid for user-context services.

Please sign in to comment.