Clarification on upstart-0.5 and dbus usage

Scott James Remnant scott at
Wed Jun 18 23:44:13 BST 2008

On Wed, 2008-06-18 at 15:21 -0700, Garrett Cooper wrote:

> Would the definition of "simple case" be a straight up SIGCHLD?
If the process dies, Upstart will receive SIGCHLD, and if marked
"respawn" it will be restarted.

Detecting things like a stoned process is more interesting.

You'd want to do something like this on a regular interval:

 [via D-Bus] obtain job object from Upstart controller

	(if none, assume job has gone away and exit)

 [via D-Bus] obtain running instance object

	(if none, assume job is disabled and exit)

 [via D-Bus] obtain process id of main job

	(if you need it for your poking)
	(if none, assume Upstart is respawning job and sleep)

 do whatever you need to do to the process to determine whether it is
 alive or stoned

 if stoned, you can simply KILL the process knowing that Upstart will
 respawn it, or

 [via D-Bus] execute the Restart() method on the instance

This is actually where D-Bus really benefits.  Upstart's model is much
more complex and flexible than sysvinit's, so you need to be able to be
quite expressive across IPC.

There's already native D-Bus bindings in just about every language you
can care to think of, so that's a huge amount of coding you don't need
to do.

For example, that might look in Python:

	import dbus

	bus = dbus.SystemBus()
	upstart = bus.get_object("com.ubuntu.Upstart",

	    job = upstart.GetJobByName("my_job")
	    instance = upstart.GetInstanceByName("")
	    # No such job, or not running

	# Note this bit may change
	    pid = instance.Get("pid")["main"]
	except KeyError:
	    # Being started, stopped or restarted

	# Muck around with pid as you see fit
	if os.path.isfile("/tmp/%d" % pid):

	# Oh dear, it's broken

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 : 

More information about the upstart-devel mailing list