Implementing a state machine in upstart (0.5)
Kees Jongenburger
kees.jongenburger at gmail.com
Fri Jan 30 11:13:10 GMT 2009
Hello
I am trying to use upstart in an embedded environment. The system
doesn't use sysv 5 runlevels
but is implemented as a state machine.
The chosen approach is to create jobs file that are called states and
make services dependent on that
so for example we have "state_boot" "state_mass_storage" and "state_app"
A sample service is something like "service_mass_storage" that will
export the file system. This service will most probably
be started automatically when a certain state is reached.
start on starting state_mass_storage
stop on stopping state_mass_storage
exec "export file system"
We also choose to implement the state change logic inside upstart, We
therefore created a change_handler
job that reacts on different events from the system. System event are
propagated using emits.
so for example apmd will emit a low_battery or suspend , udevd will
emit a "pc detected" to upstart and the change handler
might decide what to do depending on the current state. (we can not
just shutdown when in "state_app" mode
while we could in other modes).
I am facing the following problems:
My change handler is defined to "start on event_a or event_b......"
the problem with that is that if an event is generated
while the change_handler is running upstart simply skips starting my
change_handler and I miss event. I think that because it's already
running but I am not sure
To keep my state machine in a consistent state I can only run a single
instance of the handler but still want to get all the events is that
possible?
I noticed that the "on bounce" behavior found in
http://upstart.ubuntu.com/getting-started.html was not working
would emitting 5 bounces create 5 instances or run 5 time the talks
one after the other?
Greetings
More information about the upstart-devel
mailing list