Correct way to install a custom upstart service
I am using upstart for services on my servers. Writing a conf file and placing it in /etc/init
is easy enough, but that doesn't seem to completely install. For one, the service --status-all
doesn't list my new service. I checked and if I make a link in /etc/init.d
to /lib/init/ubstart-job
it'll show up in the status. But doing this manually makes me think I'm not doing it right, and there may well be other configuration steps which aren't being done.
What is the correct way to install an upstart service such that it is properly registered in all tools dealing with services?
Solution 1:
When you initially copy a new conf file into the /etc/init folder you need to call:
initctl reload-configuration
By this your upstart should be properly registered.
Solution 2:
Checkout the service manual:
service --status-all runs all init scripts, in alphabetical order, with the status command. This option only calls status for sysvinit jobs, upstart jobs can be queried in a similar manner with initctl list.
(emphasis added)
That's why adding it to /etc/init.d (where the sysvinit jobs are located) made that work. So: try running initctl list instead :) .
Solution 3:
For SysV Services
Make sure that you follow the following steps while adding/creating new service in Ubuntu.
- Create the service file in
/etc/init.d/<service name>
chmod 700 /etc/init.d/<service name>
update-rc.d <service name> defaults
update-rc.d <service name> enable
Now see you service in
service --status-all
Solution 4:
I've found that an error in the .conf file can make the job not recognizable to initctl. for example, having a setuid
line in Upstart version 1.3 or earlier.
Solution 5:
While the current chosen answer is correct for getting the new service added to upstart, it's not particularly helpful for finding out WHY a config in /etc/init/ is failing to load -- the missing piece is using init-checkconf first to make sure your config is valid, and then using reload-configuration:
####Test the new config - resolving any issues before continuing:
ERROR: File /etc/init/test.conf: syntax invalid:
test.conf:35: Unterminated quoted string
####then fix and recheck:
# init-checkconf /etc/init/test.conf
File /etc/init/test.conf: syntax ok
####then reload:
# initctl reload-configuration
#### and start:
# start test