Been pulling my hair out over this off and on for a while now. I still cannot get SABnzbd to run if the user is not root. It just won't run at all. No logs or anything. I've made double sure the permissions are correct (to the extent of chowning the whole python directory to _sabnzbd). At some point in trying to get it to run as a non-root user I started getting this messed up error in the 'Warnings' link and I can't get rid of it. I've gone through so many attempts to fix this I've lost count. So here is where I'm currently at:
1. Downloaded the source tarball and extracted to /usr/local/src
2. Modified SABnzbd.py to point to /usr/local/bin/python
3. Ran SABnzbd.py as root. It does not crash on step 5 anymore! Moved the resulting config files to /usr/local/etc/sabnzbd
4. Cobbled together this rc.d script from the one that comes with the sabnzbdplus port and one I found here on the forums. Neither worked completely properly alone and neither does mine (shutdown takes about 5 minutes, although it actually does shut down unlike the originals which would just hang forever).
Code: Select all
#!/bin/sh
. /etc/rc.subr
name="sabnzbd"
rcvar=${name}_enable
load_rc_config ${name}
: ${sabnzbd_enable:="NO"}
: ${sabnzbd_user:="root"}
: ${sabnzbd_group:="wheel"}
: ${sabnzbd_conf_dir:="/usr/local/etc/sabnzbd"}
required_dirs=${sabnzbd_conf_dir}
status_cmd="${name}_status"
stop_cmd="${name}_stop"
start_precmd=sabnzbd_check_dir
command="/usr/sbin/daemon"
command_args="-f /usr/local/src/SABnzbd-0.5.6/SABnzbd.py ${sabnzbd_flags} --daemon -b 0 -w 0 -l 0 -f ${sabnzbd_conf_dir}"
# SABnzbd can only be cleanly stopped by calling the http api
sabnzbd_stop() {
echo "Stopping $name"
if [ -f "${sabnzbd_conf_dir}/sabnzbd.ini" ]; then
apikey=`grep ^api_key ${sabnzbd_conf_dir}/sabnzbd.ini | tr -d " _"`
host=`grep -E '^host\ =\ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9].'`
if [ ${host}="0.0.0.0" ] ; then host="localhost" ; fi
port=`grep -m1 ^port ${sabnzbd_conf_dir}/sabnzbd.ini | tr -dc '[0-9]'`
fetch -o /dev/null "http://${host}:${port}/api?mode=shutdown&${apikey}" > /dev/null 2>&1
else
sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'`
if [ -n "${sabnzbd_pid}" ]; then
kill ${sabnzbd_pid}
fi
fi
}
sabnzbd_status() {
sabnzbd_pid=`ps -U ${sabnzbd_user} | grep "python.*SABnzbd.py.*--daemon" | grep -v 'grep' | awk '{print $1}'`
if [ -n "${sabnzbd_pid}" ]; then
echo "$name is running as ${sabnzbd_pid}"
else
echo "$name is not running"
fi
}
sabnzbd_check_dir() {
if [ ! -f "${required_dirs}" -a ! -d "${required_dirs}" -a ! -L "${required_dirs}" ]; then
mkdir -p ${required_dirs}
chown ${sabnzbd_user}:${sabnzbd_group} ${required_dirs}
fi
}
run_rc_command "$1"
5. Okay, it starts up and actually works. Or so it seems. After about 5 minutes this error appears in the 'Warnings" link:
Code: Select all
2011-04-10 23:20:55,433 ERROR: [10/Apr/2011:23:20:55] ENGINE Error in 'start' listener <bound method Server.start of <cherrypy._cpserver.Server object at 0x802ad1750>> Traceback (most recent call last): File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 147, in publish output.append(listener(*args, **kwargs)) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/_cpserver.py", line 90, in start ServerAdapter.start(self) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 62, in start self.wait() File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 103, in wait wait_for_occupied_port(host, port) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 275, in wait_for_occupied_port raise IOError("Port %r not bound on %r" % (port, host)) IOError: Port 8080 not bound on '0.0.0.0'
2011-04-10 23:20:55,434 ERROR: [10/Apr/2011:23:20:55] ENGINE Shutting down due to error in start listener: Traceback (most recent call last): File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 184, in start self.publish('start') File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/wspbus.py", line 147, in publish output.append(listener(*args, **kwargs)) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/_cpserver.py", line 90, in start ServerAdapter.start(self) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 62, in start self.wait() File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 103, in wait wait_for_occupied_port(host, port) File "/usr/local/src/SABnzbd-0.5.6/cherrypy/process/servers.py", line 275, in wait_for_occupied_port raise IOError("Port %r not bound on %r" % (port, host)) IOError: Port 8080 not bound on '0.0.0.0'
2011-04-10 23:20:55,439 ERROR: Failed to start web-interface
6. With a little bit of playing around that I found if I set "host" in sabnzbd.ini to anything BUT 0.0.0.0 it will crash a few minutes after this. With 0.0.0.0 I still get the error, however everything *seems* to work okay with one exception. SABnzbd will still not shut down / restart through the web interface (I have to do ps -ax and kill -9 the pid). It will also crash in the exact same manner if I enable SSL. This one is a real head-scratcher for me. I don't really know anything about python. I tried to look in the python files mentioned, but I couldn't really make head nor tails out of it (I'm not a programmer. I made a crappy PHP website for a class once, and I'm sure it would fall over if you looked at it funny.)