Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd service #113

Open
ghost opened this issue Jan 28, 2017 · 4 comments
Open

systemd service #113

ghost opened this issue Jan 28, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 28, 2017

Related to #49

I've been trying to get spotifyconnectweb working seperately on a Raspberry Pi 3 headless installation and had quite a bit of problems creating a systemd service without a seperate script that cd into the directory before running spotifyconnectweb on a new line. What I've learned with help from looking at other peoples' scripts and trial and error is that unless you create a seperate script like mentioned, it seems to be very picky about accepting arguments such as --username, --password, --key etc. It just produces an error when attempting to start the service via systemctl start $servicename and doesn't start the service.

It works fine if I use the chrooted version, but not the smaller one with built-in dependencies, which is preferrable to me.

So I solved this by specifying the locations manually, which worked perfectly.

ExecStart=/pathto/spotifyconnectweb -k /pathto/spotify_appkey.key -n "Spotify Connect" -b 320 -c /pathto/credentials.json

So on my Raspbian install I have created the following service as /etc/systemd/system/spotify-connect.service

[Unit]
Description=Spotify Connect
After=network.target
Requires=network-online.target

[Service]
ExecStart=/pathto/spotifyconnectweb -k /pathto/spotify_appkey.key -n "Spotify Connect" -b 320 -c /pathto/credentials.json
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target

After that I just enabled started and enabled the service

sudo systemctl start spotify-connect
sudo systemctl enable spotify-connect

Just wanted to share this in case it helps anyone else that may be experiencing similar issues. Thank you again for your great implementation, my next issue to tackle will be starting Avahi on boot.

Would it be recommended to just add this line of code to /etc/rc.local ?
avahi-publish-service TestConnect _spotify-connect._tcp 4000 VERSION=1.0 CPath=/login/_zeroconf

Any suggestions or better implementations are welcomed!

@jdrossl
Copy link

jdrossl commented Feb 14, 2017

This works great! but you should also add the working directory param or the web ui will not work properly.

WorkingDirectory=/pathto/

@ghost
Copy link
Author

ghost commented Feb 14, 2017

Ah, I haven't actually used the web ui. maybe we should pool our knowledge and add it to the wiki.

Would be great to add the option to start it as a service to the default packaging some how. I am not savvy when it comes to bash scripts, so I would have to look into this.

@ashthespy
Copy link

ashthespy commented Mar 4, 2017

Tried following your steps also with Rasbian,

Created /etc/systemd/system/spotify-connect.service

[Unit]
Description=Spotify Connect
After=network.target
Requires=network-online.target

[Service]
WorkingDirectory=/home/pi/spotify-connect-web/
ExecStart=/home/pi/spotify-connect-web/spotify-connect-web -k /home/pi/spotify-connect-web/spotify_appkey.key -n "Spotify Connect" -b 320 -c /home/pi/spotify-connect-web/credentials.json -o "sysdefault:CARD=Audio"
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target

However when checking the status of the service after starting it, I get

● spotify-connect.service - Spotify Connect
   Loaded: loaded (/etc/systemd/system/spotify-connect.service; enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2017-03-04 17:45:37 CET; 3s ago
 Main PID: 1533 (code=exited, status=255)

Mar 04 17:45:37 raspberrypi systemd[1]: spotify-connect.service: main process exited, code=exited, status=255/n/a
Mar 04 17:45:37 raspberrypi systemd[1]: Unit spotify-connect.service entered failed state.

I am however able to get it working just fine via ssh by running

/home/pi/spotify-connect-web/spotify-connect-web -k /home/pi/spotify-connect-web/spotify_appkey.key -n "Spotify Connect" -b 320 -c /home/pi/spotify-connect-web/credentials.json -o "sysdefault:CARD=Audio"

Any ideas?

@ghost
Copy link
Author

ghost commented Mar 4, 2017

@ashthespy
I'm no expert, but have you tried without

WorkingDirectory=/home/pi/spotify-connect-web/

and without -o "sysdefault:CARD=Audio"

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants