Help with respawn

Scott James Remnant scott at netsplit.com
Mon Apr 23 11:00:43 BST 2007


On Thu, 2007-04-19 at 08:08 +0200, Matthias Urlichs wrote:

> > A simple initctl "hello, my pid is now XXX" control message should be
> > sufficient.
> 
> I just wanted to checkout the latest version in Launchpad to see how
> easy it would be to add that feature, and noticed that the last bzr
> upload was five weeks ago.
> 
I've been somewhat busy with the release of feisty ;)

And there's nothing immediately to work on, the next thing to be
implemented is "complex event config" which hasn't yet reached a decent
draft state -- so development is having a relax for a few weeks.

To answer the original question ...

If you look at the state graph (doc/states.png) you'll see that there's
a state in there marked as follows...

	spawned
	(wait for pid)

sitting between pre-start and post-start; using "start" on a job will
show you that all jobs pass through this state.

Search for JOB_SPAWNED in init/job.c and you'll see the entry in the
state transition switch; in this state, upstart does the following...

	runs the main process
	moves to the next state IF the job isn't marked "daemon"

You'll find that the "daemon" keyword is already implemented in the
configuration file; using it in a job will cause it to stick in the
"spawned" state rather than moving through to "running".

The TODO is finding ways OUT of the spawned state.

Typical examples are:

	finding a pid file
	finding a process in /proc with a particular binary
	receiving an initctl message

(the last of those is also useful for non-forking daemons that want to
inform upstart when they're ready).

Scott
-- 
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/upstart-devel/attachments/20070423/e2b2150e/attachment.pgp 


More information about the upstart-devel mailing list