Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [Solved] Sabnzbd Fails to Launch as a Service (Read 660 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

[Solved] Sabnzbd Fails to Launch as a Service

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,

Code: [Select]
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?

Re: [H] Sabnzbd Fails to Launch as a Service

Reply #1
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:

Code: [Select]
PATH=/bin:/usr/bin

Make sure to include any directory containing executables that sabnzbd expects to be able to find on the PATH.

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #2
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.

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #3
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

Code: [Select]
env-file   = /etc/dinit.d/environment

Where the content of environment is simply
Code: [Select]
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?

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #4

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.

Code: [Select]
zeus@9600k:~$ cat bin/sab_start.sh
#!/bin/bash

# A script to start sabnzbd
/usr/lib/sabnzbd/SABnzbd.py & >/dev/null 2>&1

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #5
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:

Code: [Select]
  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:

Code: [Select]
#!/bin/sh

export PATH="/bin:/usr/bin"
/usr/lib/sabnzbd/SABnzbd.py -l0 -f /var/lib/sabnzbd/sabnzbd.ini

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #6
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).

Re: [Solved] Sabnzbd Fails to Launch as a Service

Reply #7
Quote
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

I'm pretty sure I also tried that, but for some reason it now works. Thanks   :D