Page 1 of 1

Ubuntu systemd script for PPA

Posted: January 21st, 2017, 7:42 am
by mason
Hey there,

since I'm in the process of swapping my old 12.04 server to new hardware and 16.10 I stumbled over a missing systemd script for sabnzbd. So after some digging, here are my findings to share. Maybe it's helping someone.

Create a new systemd script with

Code: Select all

sudo nano /etc/systemd/system/sabnzbd.service
Add the following:

Code: Select all

[Unit]
Description=Sabnzbd
Wants=network-online.target
After=network-online.target

[Service]
User=sabuser
Group=sabuser
RuntimeDirectory=sabnzbdplus
RuntimeDirectoryMode=0750
ExecStart=/usr/bin/python2.7 /usr/bin/sabnzbdplus --config-file /home/sabuser/.sabnzbd/sabnzbd.ini --logging 1 --daemon
Type=forking

Restart=on-failure

[Install]
WantedBy=multi-user.target
Some things I fell over. We need to create the sabnzbd pid dir in /var/run due to the fact that we running under a different user which has no permissions there. So that's what's the RuntimeDirectory directive is for.
Make sure you edit the user, location of the ini file and port to match your configuration. Type is forking since sabnzbd spawns other threads.

Enable the systemd with:

Code: Select all

sudo systemctl enable sabnzbd.service 
Then just start with

Code: Select all

sudo service sabnzbd start
and you should be good. Hope this might help somebody... finally could give something back. :)

Cheers

Re: Ubuntu systemd script for PPA

Posted: January 23rd, 2017, 1:54 pm
by jcfp
Have been thinking about adding a systemd service for a while, but haven't so far as I'm still looking for the best way to handle existing users during upgrade, initial service configuration, and related systemd "features".

And just for the record: without a native service, systemd will simply use the good old init.d script.

Re: Ubuntu systemd script for PPA

Posted: January 23rd, 2017, 2:51 pm
by mason
Also looks like it having a flaw, if your restart in the browser, it won't come back.... need to have another look.

Now it's working as it should, and proper restarting from the GUI.