Error when running service

Get help, report and discuss bugs.
Post Reply
void.pointer
Posts: 60
Joined: 28 Sep 2014, 20:58

Error when running service

Post by void.pointer » 17 Sep 2015, 02:55

I have the following upstart script in Ubuntu 15 for nzbget:

Code: Select all

description "NZBGet upstart script"

setuid robert
setgid robert

start on runlevel [2345]
stop on runlevel [016]

respawn

expect fork

script
    exec nzbget -D
end script

pre-stop script
    exec nzbget -Q
end script
This used to work fine in Ubuntu Server 14, but then I upgraded to 15, rebuilt nzbget, and service won't work anymore. However, I am able to run "nzbget -D" manually just fine and everything works in that case. It's just the service. To rebuild everything after upgrading ubuntu, I ran these commands:

Code: Select all

$ git reset --hard && git clean -fdx
$ ./configure
$ make -j8
$ sudo make install
Then I ran "sudo service nzbget start" and I get the below error:

Code: Select all

Failed to start nzbget.service: Unit nzbget.service failed to load: No such file or directory.
Any ideas? Thanks.

void.pointer
Posts: 60
Joined: 28 Sep 2014, 20:58

Re: Error when running service

Post by void.pointer » 17 Sep 2015, 03:34

After some research, it looks like Ubuntu Server v15 switched to "systemd" to manage services. So my upstart script wasn't working anymore. After toying around, I came up with the following nzbget systemd unit:

(Named "nzbget.service")

Code: Select all

[Unit]
Description=NZBGet Service

[Service]
Type=forking
ExecStart=/usr/local/bin/nzbget -D
ExecStop=/usr/local/bin/nzbget -Q
Restart=on-failure
I placed this at the following path:

Code: Select all

~/.config/systemd/user/nzbget.service
And to start the service, you do this:

Code: Select all

$ systemctl --user start nzbget
To stop the service, you do:

Code: Select all

$ systemctl --user stop nzbget
Works great now. I haven't verified if nzbget starts up on boot, I will look into that soon.

morpheus
Posts: 9
Joined: 10 Jul 2015, 12:39

Re: Error when running service

Post by morpheus » 23 Sep 2015, 12:02

void.pointer wrote:After some research, it looks like Ubuntu Server v15 switched to "systemd" to manage services. So my upstart script wasn't working anymore. After toying around, I came up with the following nzbget systemd unit:

(Named "nzbget.service")

Code: Select all

[Unit]
Description=NZBGet Service

[Service]
Type=forking
ExecStart=/usr/local/bin/nzbget -D
ExecStop=/usr/local/bin/nzbget -Q
Restart=on-failure
You may wish to add

Code: Select all

ExecReload=/usr/local/bin/nzbget -O
after the "ExecStop" line so systemd knows how to handle a reload command for your NZBGet service.

Try

Code: Select all

sudo systemctl enable nzbget.service
to tell systemd to start NZBGet up on a reboot.

Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests