Ubuntu Autostart failing


#1

Hello,

I have another question: I try to get the sickrage installation to autostart on Ubuntu 16.04.
I copied the service file from runscripts and the init file from runscripts. Also, I wrote the defaults with update-rc.d.
When I’m starting the service manually it works (it just needs a minute or two till the web server is responding?). But if I reboot the machine the service isn’t started.
But I see in the syslog that the service has been started.
After the reboot the service status says

● sickrage.service - SickRage Daemon
Loaded: loaded (/etc/systemd/system/sickrage.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2018-11-05 20:01:03 CET; 9min ago
Process: 899 ExecStart=/usr/bin/python2.7 /opt/sickrage/SiCKRAGE.py -q --daemon --nolaunch --datadir=/opt/sickrage (code=exited, status=0/SUCCESS)

Nov 05 20:00:59 saraswati systemd[1]: Starting SickRage Daemon...
Nov 05 20:01:02 saraswati systemd[1]: Started SickRage Daemon.

So it looks like the service is immediately killed after it started.

Does anybody have ideas why?

Thanks for your help!


#2

I fiddled around and I think I found the error:
So first of all for Ubuntu 16.04 just systemd is relevant, the marked ubuntu runscript is not used at all.
Then in the service file a line was missing at Unit:

After=network-online.target

I also added a few more lines at Service:

Restart=on-failure
TimeoutStopSec=300

And then the service must be enabled with:

sudo systemctl enable sickrage.service

My full sickrage.service file looks like that now:

[Unit]
Description=SickRage Daemon
After=network-online.target
[Service]
User=sickrage
Group=sickrage
Type=forking
GuessMainPID=no
ExecStart=/usr/bin/python2.7 /opt/sickrage/SiCKRAGE.py -q --daemon --nolaunch --datadir=/opt/sickrage
Restart=on-failure
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target

Hope that helps anybody