Upstart recipe for non-forking daemons

Do you need to start your non-forking daemon on Ubuntu Server 15.04? You can use this recipe.

I know that probably systemd will be the default init system even in Ubuntu Server 15.04 but, in the mean time, we have Ubuntu Server 14.04.2 and on that OS the init system is Upstart.

It turns out that Upstart has an introduction here. It is well written and understandable.

If your daemon daemon:

  • don’t fork;
  • can simply been stopped by a SIGSTOP
  • logs to the console;

you can write a job description like the following one. It has to be placed in /etc/init/[yourname.conf].

description	"Your description here"

start on runlevel [2345]
stop on runlevel [!2345]

env [any environment variables you may need]
setuid [the users that the daemon will run as]

exec [the name of your daemon here]

Than you can use the following commands:

$ service start <jobname>   # starts the job
$ service stop <jobname>    # stops the job
$ service status <jobname>  # gets the service status

The output of your daemon will be in /var/log/upstart/[jobname]. Isn’t that sweet?

Upstart recipe for non-forking daemons

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s