NzbDrone and FreeBSD/Freenas

Status
Not open for further replies.

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Is that not created by default?
depends how your user was created. I have no idea how you guys are setting this program up.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
I was using the pw command to add groups/users
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I was using the pw command to add groups/users
depending on the flags you gave it would or would not create the home directory.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
I just created a new jail and setup the user, this time using adduser and I ensured that a home directory was created. But still, nzbdrone will not start, when I run
Code:
service nzbdrone start
I do not get any errors, neither mono or nzbdrone is starting.

Edit: I wonder if I need to add the user to the "wheel" group, because I believe mono needs elevated privileges to run.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I just created a new jail and setup the user, this time using adduser and I ensured that a home directory was created. But still, nzbdrone will not start, when I run
Code:
service nzbdrone start
I do not get any errors, neither mono or nzbdrone is starting.

Edit: I wonder if I need to add the user to the "wheel" group, because I believe mono needs elevated privileges to run.
I think errors would be directed to the log so you could check there?
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Also check that the log file and the pid file are owned by the correct user, or not created at all (in which case it will be created at first run).
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Looks good. Mind checking if my changes works

Changes I made
  • I simplified nzbdrone_poststart() to utlize a built in variable
  • no need deleting a stale pidfile then overwriting it. just overwriting it would do the same thing.
  • utilized nzbdrone_dir
Future changes

  • can you specify "nzbdrone_data_dir" as a commandline flag to nzbdrone? if so maybe we should specify it to something like /usr/local/etc/nzbdrone (but this directory would need to be owned by nzbdrone_user). otherwise the variable can be deleted, it's not being used.
  • if the above is implemented we might want to specify a user other than nobody to own the config files. it would need to either be a built in account, or people would need to add it. (though this is something a port maintainer would need to think about, not something that needs to be taken care of in this script)
Code:
#!/bin/sh
 
#
# PROVIDE: nzbdrone
# REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# nzbdrone_enable (bool):    Set to NO by default.
#            Set it to YES to enable it.
# nzbdrone_data_dir:    Directory where nzbdrone configuration
#            data is stored.
#            Default: /home/${nzbdrone_user}/.config/NzbDrone
# nzbdrone_user:    The user account nzbdrone daemon runs as what
#            you want it to be. It uses 'nobody' user by
#            default. Do not sets it as empty or it will run
#            as root.
# nzbdrone_group:    The group account nzbdrone daemon runs as what
#            you want it to be. It uses 'user' group by
#            default. Do not sets it as empty or it will run
#            as wheel.
 
. /etc/rc.subr
name="nzbdrone"
rcvar="${name}_enable"
load_rc_config $name
start_postcmd="${name}_poststart"
pidfile="/var/run/${name}.pid"
stop_postcmd="${name}_poststop"
 
 
: ${nzbdrone_enable:="NO"}
: ${nzbdrone_user:="nobody"} #NOTE: DO NOT RUN AS ROOT, IT WILL BURN YOUR HOUSE DOWN AND RAPE YOUR CAT!
: ${nzbdrone_group:="user"}
: ${nzbdrone_dir:="/opt/NzbDrone"}
: ${nzbdrone_data_dir:="/home/${nzbdrone_user}/.config/NzbDrone"}
: ${nzbdrone_log:="/var/log/nzbdrone.log"}
 
command="/usr/local/bin/mono"
command_args="$nzbdrone_dir/NzbDrone.exe >$nzbdrone_log 2>&1 &"
nzbdrone_poststart()
{
        echo $rc_pid > $pidfile
}
nzbdrone_poststop()
{
        rm $pidfile
}
run_rc_command "$1"

Seems to work fine. I'll commit it to github.

The reason I have the data_dir in the file is simply to remind myself where it is, but yes - there should be a way to feed the info to nzbdrone. The problem is there is no current way to do that in nzbdrone. TL;DR: Take it up with upstream developer ;)

I have no idea which user should do this. I have a built-in user which has ownership of all my media files, so I use that user for all "file gathering purposes". There are many users in freenas - too many I think, but none I can think of that fit the bill.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Also check that the log file and the pid file are owned by the correct user, or not created at all (in which case it will be created at first run).

I ended up getting it to work. For some reason the /home directory was not present. So I deleted the user and created a /home directory. Then I re-created the user and this time it automatically created the proper user's home directory under /home

I have one other issue though. I am not sure if you had this issue, but sometimes I found that NzbDrone would crash. At first I thought it really only did it when searching for many episodes at once, but this wasn't the case because I would check to see if its running every couple of days and a lot of the time it wasn't. Now I yesterday I did create a new jail and update to the latest mono and sqlite versions, so that may help. But I am also wondering if you have seen this same issue. Also is there a way to have nzbdrone restart automatically if it crashes?
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Look at monit, it's in ports. Here's a pretty basic monitrc snippet which works with this rc-script:

Code:
check process nzbdrone with pidfile /var/run/nzbdrone.pid
  start program = "/usr/sbin/service nzbdrone start"
  stop program = "/usr/sbin/service nzbdrone stop"
  if failed host 0.0.0.0 with port 8989 then restart
  if 5 restarts within 5 cycles then timeout
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Look at monit, it's in ports. Here's a pretty basic monitrc snippet which works with this rc-script:

Code:
check process nzbdrone with pidfile /var/run/nzbdrone.pid
  start program = "/usr/sbin/service nzbdrone start"
  stop program = "/usr/sbin/service nzbdrone stop"
  if failed host 0.0.0.0 with port 8989 then restart
  if 5 restarts within 5 cycles then timeout

Where would this script be placed? In the rc.d folder?
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
/usr/local/etc/monitrc
There will be a monitrc.default or something there as well if you want to learn more
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
/usr/local/etc/monitrc
There will be a monitrc.default or something there as well if you want to learn more

Okay, thanks.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Nzbdrone still seems to be very unstable, I suspect it's mono. I do not see any errors in the nzbdrone log, basically the back end will lose connectivity to the web interface and I can see the mono service still running. Usually restarting nzbdrone will fix the issue, but sometimes I have to restart the jail. This seems to happen usually when searching for episodes for a whole season or just when searching for many episodes at one time.

I am just curious if tofagerl you have also noticed any of these issues or that maybe this is something on my end.

I did setup the monit script, but this does not seem to help because when the problem occurs the service is usually still running, so monit does not know to restart the service.
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Yes, and if it loads the site, but the site isn't actually working, it won't notice :(

I don't have your problems, but I do have similar ones. I know that nzbdrone is going through a pretty heavy coding phase, so I would suggest trying other builds back in time until you find one that works for you, and then every time a new build gets pushed as a release (not just a daily) try to see if it works for you, but don't overwrite the existing build until you're sure it's good.

That's what I'm doing anyway. The development is going REALLY fast, and that's when bumps in the road turn into crashes...
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Yes, and if it loads the site, but the site isn't actually working, it won't notice :(

I don't have your problems, but I do have similar ones. I know that nzbdrone is going through a pretty heavy coding phase, so I would suggest trying other builds back in time until you find one that works for you, and then every time a new build gets pushed as a release (not just a daily) try to see if it works for you, but don't overwrite the existing build until you're sure it's good.

That's what I'm doing anyway. The development is going REALLY fast, and that's when bumps in the road turn into crashes...

Yeah, I will keep trying new versions. It will be nice to one day move away from sickbeard completely, because I do like nzbdrone a lot. Generally once nzbdrone settles down and is just downloading daily episodes it seems to work most of the time.

I also did notice that the change permissions feature seems to not function, it throws an error that it could not change the permissions of the files. The user that nzbdrone runs as has full permissions to create/modified files in the dataset, but again this may just be more growing pains as development continues.
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
That permissions thing is probably for the nzbdrone forums to figure out. Markus is pretty good about answering questions and picking up bug reports there.

Btw, I pushed a few changes to the rc-file now. It seems good now.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
may I all what nzbdrone does that sickbeard doesn't? don't want to start a holy war, but SB does everything I need to do quickly and as expected.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Also there are some shows that SB does not download properly due to episode mismatches. ND also has a much better interface with more control over your downloads.

I also found that the permissions option is going to be removed because it does not function as intended.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
It sees that downloads fail and find a new one.
yeah, the regular SB branch doesn't have that. have you guys tried The Pirate Bay branch recently? tolstyak's 'failed' branch merged into it a few months ago so it has failed download support now. if you Google 'jruehlig freenas' I have my setup outlined which enables this feature.
 
Status
Not open for further replies.
Top