Background: When launching sabnzbd as a user, it launches without fault, by calling
python /usr/lib/sabnzbd/SABnzbd.py. However, when wanting to manage this as a daemonised service, it fails. The service file reads,
type = process
command = /usr/lib/sabnzbd/SABnzbd.py -l0 -f /var/lib/sabnzbd/sabnzbd.ini
logfile = /var/log/dinit/sabnzbd.log
waits-for = loginready
run-as = sabnzbd
The log outputs an error related to parsing PATH, stating
AttributeError: 'NoneType' object has no attribute 'split'. I am confused by this since this error only occurs when launched as a service.
Does anybody have any recommendation to solve this error?
It seems like sabnzbd is not correctly dealing with the case where the PATH environment variable is not set (and that it is not being set in the /etc/dinit/environment file).
The easiest solution is probably just to add a reasonable setting for PATH to /etc/dinit/environment.
I suggest something like:
PATH=/bin:/usr/bin
Make sure to include any directory containing executables that sabnzbd expects to be able to find on the PATH.
Thank you.
For future readers, also add a line in the service file to read the environment file, either env-file = or load-options = , although the latter is discouraged.
Hey, reader from the future here. I seem to have the same problem as you, service won't start because $PATH is undefined. So far nothing seems to work.
I tried to set
env-file = /etc/dinit.d/environment
Where the content of environment is simply
PATH=/bin:/usr/bin
. (Also no luck with load-options).
I also tried to load a script inside
command =, where I first export PATH before starting sabnzb, but this also didn't work.
Any idea what I'm missing?
What path are you using? This works perfectly fine for starting it on my install.
zeus@9600k:~$ cat bin/sab_start.sh
#!/bin/bash
# A script to start sabnzbd
/usr/lib/sabnzbd/SABnzbd.py & >/dev/null 2>&1
The part of the script that is supposed to start sab is working (when running it manually), its that the PATH variable is not handed to dinit or the service or whatever.
The Error Message is:
File "/usr/lib/sabnzbd/sabnzbd/misc.py", line 995, in find_on_path
paths = os.getenv("PATH").split(":")
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'split'
The script itself is very basic and based on the comments of this post:
#!/bin/sh
export PATH="/bin:/usr/bin"
/usr/lib/sabnzbd/SABnzbd.py -l0 -f /var/lib/sabnzbd/sabnzbd.ini
I created a file as follows (create directory if necessary): /etc/dinit/environment
The content within the file is PATH=/bin:/usr/bin as previously suggested.
Specify your service file as in the initial post, but add the line: env-file = /etc/dinit/environment
This should then have sab run without flaws. This is necessary if you want to run sab as a service under its own user (it will otherwise work fine when executed by your user).
I'm pretty sure I also tried that, but for some reason it now works. Thanks :D