Reputation: 1119
I am currently attempting to start Luigid when my Ubuntu server turns on, I have tried several techniques including rc.local, cronjob(@reboot), upstart, systemd and none of them appear to be working.
I should point out that the command runs fine if I do it manually, I just need it to run on startup. At this point I really don't have any concern which way I get it to work so here are some of the things I've tried -
Cron:
Used
sudo crontab -e
and entered
@reboot luigid --background --logdir /home/myuser/luigilog
Systemd:
I have a script in /usr/bin called luigid with the following contents, it is marked as executable, and I have tried it with and without "exit 0" fearing a proper exit code might be required -
#!/bin/sh
exec luigid --background --logdir /home/myuser/luigilog
and a service file in /etc/systemd/system/ called luigid.service -
[Unit]
Description=Luigid Service
[Service]
Type=forking
ExecStart=/usr/bin/luigid
[Install]
WantedBy=multi-user.target
I have tried forking(and specifying the PIDfile in both the service and in the lugid command, oneshot and simple as the types with no luck.
I have enabled the service using -
systemctl enable luigid.service
It appears it attempts to start the service because checking the status using
systemctl status luigid.service
shows
luigid.service - Luigid Service
Loaded: loaded (/etc/systemd/system/luigid.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Mon 2016-10-10 15:18:00 UTC; 18min ago
Oct 10 15:16:29 Analytics systemd[1]: Starting Luigid Service...
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Start operation timed out. Terminating.
Oct 10 15:18:00 Analytics systemd[1]: Failed to start Luigid Service.
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Unit entered failed state.
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Failed with result 'timeout'.
There must be something obvious I'm missing, it really can't be this hard to get a command to run on startup!
Upvotes: 3
Views: 1162
Reputation: 13381
Reviewing the startup options: Neither "rc.local" and "cron @reboot" will help you if the service crashes later, so they aren't ideal. Since it appears you have a systemd-based system, then Upstart isn't really an option. systemd
is a good option to focus on because it will not only start your process, but also restart it if it crashes.
I don't know what the right option for Type=
is for this service, but it does matter. Check the docs for Type=
in man systemd.service
to determine which one is correct for your service.
Your wrapper script shouldn't be required. You should be able to have an ExecStart=
line like this:
ExecStart=/usr/bin/luigid --background --logdir /home/myuser/luigilog
I would also try removing the --background
option and setting the Type=
to simple
if you haven't tried that combination.
If you can't get it to work, try get your daemon to provide more verbose logging about why it's not starting, or resort to adding /usr/bin/strace
to the beginning of your ExecStart=
line to get detailed logging of the system calls that the binary is making during startup. One of the final few calls could point to where it is hanging.
Upvotes: 4