Page 1 of 1

Another thread titled "cannot get Sabnzbd to run as service"

Posted: March 16th, 2025, 9:27 am
by UncleBanglin
Hello,

As the title alludes, I am pulling my hair out over not being able to figure this out. In case it doesn't go without saying, I have read about a dozen threads on the same topic here, stackoverflow, askubuntu etc...none of them have yielded a solution for me.

I've run sabnzbd on my server for a few years now, recently logged in and noticed sonarr said "all download clients unavailable" and started poking around. Didn't see anything obviously wrong with my setup. Didn't know what to do, so I uninstalled and reinstalled for a clean start. I can start sabnzbdplus from the terminal and access it from a web browser just fine. But something is wrong with my systemd setup, as I cannot seem to get that working. Based on the likely questions...

Yes, I added my username to the /etc/defaults/sabnzbdplus file

Yes, my username is one that exists per "whoami"

Here is the output of my service status

Code: Select all

parker@optiserver990:~$ sudo service sabnzbdplus status
● sabnzbdplus.service - LSB: SABnzbd+ binary newsgrabber
     Loaded: loaded (/etc/init.d/sabnzbdplus; generated)
     Active: active (exited) since Sat 2025-03-15 22:34:47 EDT; 1h 21min ago
       Docs: man:systemd-sysv-generator(8)
        CPU: 5ms

Mar 15 22:34:47 optiserver990 systemd[1]: Starting LSB: SABnzbd+ binary newsgrabber...
Mar 15 22:34:47 optiserver990 sabnzbdplus[1701]:  * SABnzbd+ binary newsgrabber: service not enabled, edit /etc/default/sabnzbdplus
Mar 15 22:34:47 optiserver990 systemd[1]: Started LSB: SABnzbd+ binary newsgrabber.
My /etc/default/sabnzbdplus file is the same one that ships with the PPA, only I added my username in the appropriate field

I'm not sure if it is a red flag or expected behavior, but I do get this when I try to enable the service

Code: Select all

parker@optiserver990:~$ sudo systemctl enable sabnzbdplus
sabnzbdplus.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable sabnzbdplus
thanks for any help or suggestions in advance!

Re: Another thread titled "cannot get Sabnzbd to run as service"

Posted: March 17th, 2025, 7:08 am
by jcfp
If the service tells you to edit its config file, that means it didn't find a username in the config. Note that there's no "s" in /etc/default, and also systemd requires that you to run

Code: Select all

sudo systemctl daemon-reload
every time you edit the config or it keeps using a cached copy.

As for the username setting, you can run the same check as the init script does in a terminal:

Code: Select all

/bin/sh -c '. /etc/default/sabnzbdplus && echo ${USER%:*}'
The script needs this value to be non-empty or it will print that "edit the config" message when starting the service.

Re: Another thread titled "cannot get Sabnzbd to run as service"

Posted: March 18th, 2025, 1:50 am
by UncleBanglin
My username came back correct, using the script you shared.

I meant to include that in the original post, but yes ... I did reload daemons for systemd

But speaking of daemons, that's where I ended up finding a fix. I deleted the systemd service that shipped at /etc/default/sabnzbdplus. Then I deleted the PPA. Then I uninstalled the program completely. Then rebooted for good measure. Then, instead of installing from the repository, I cloned the GIT and then followed the copied the service code I found when I clicked the Install as a Unix daemon link on the wiki. That led me to create this service file.

Code: Select all

[Unit]
Description=SABnzbd binary newsreader
Wants=
After=

[Service]
Environment="PYTHONIOENCODING=utf-8"
ExecStart=/home/parker/sabnzbd/SABnzbdpy --disable-file-log --logging 1 --browser 0
User=%I
Type=simple
Restart=on-failure
ProtectSystem=full
DeviceAllow=/dev/null rw
DeviceAllow=/dev/urandom r
DevicePolicy=strict
NoNewPrivileges=yes

[Install]
WantedBy=multi-usertarget
Note, I had to massage some DOTS out of that code b/c NeW UsErS cAnNoT pOsT LiNkS 😠

Effectively, the difference is my service file looks different (user specific service, didn't have the @ symbol in the filename before, and not located in /etc/default) and I am running the program with python from my home directory instead of (without python??) from /usr/bin/

Still not sure why I couldn't get installing from the PPA to work, as that's what I had done in the past. But as long as it's working, I'm good. Just gotta remember to update by pulling from git instead of relying on package managers.

Re: Another thread titled "cannot get Sabnzbd to run as service"

Posted: March 30th, 2025, 1:59 pm
by UncleBanglin
Not sure what makes it different for me, but I decided that the default config at /etc/defaults/sabnzbdplus didn't have any line to actually call a program in it. So I added the following two lines.

Code: Select all

[Service]
ExecStart=/usr/bin/sabnzbdplus --disable-file-log --logging 1 --browser 0
That and a systemctl daemon-reload got me going.