I've got a 3-rd party proprietary application server daemon which can be started and stopped by couple of command lines. I need this daemon to start when the system starts up and correctly stopped on system shutting down. How do I correctly implement this? Is it enough to copy some script inside /etc/init.d and modify it accordingly?

link|improve this question

56% accept rate
feedback

3 Answers

init.d is the old, deprecated system for starting daemons; is has been supplanted by upstart. Upstart has the advantage of being far easier to configure and allows proper sequencing of task initialization.

The configuration files for upstart live in /etc/init and if your daemon has no pre-requisites it can be as simple as tty1.conf:

# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -8 38400 tty1

in which case you can copy that file and modify to taste. More complex configurations are best documented at the upstart site and in other entries in /etc/init.

added in response to comment

Whether you use upstart or init.d, you'll still need some way of determining when Firebird is properly initialized. Unfortunately, Firebird itself doesn't seem to have a good way of verifying that it is installed and running. Therefore, the recommendation to stick your program start into /etc/rc.local is certainly the easiest, and on Ubuntu - at least - is guaranteed to run about as late as possible in the boot process.

link|improve this answer
Actually my daemon depends on Firebird database server, which uses init.d. – Ivan Dec 25 '10 at 9:59
feedback
  • Add your commands to /etc/rc.local
  • So that your daemon will get start automatically on system startup.
link|improve this answer
feedback

Make a copy of /etc/init.d/skeleton and edit it at appropriate places to start/stop/restart your service. It is very well commented so you should be able to create a working init.d script in no time.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.