Implementing a state machine in upstart (0.5)
Saravanan Shanmugham (sarvi)
sarvi at cisco.com
Fri Jan 30 18:21:33 GMT 2009
We are having the same problem.
I understand there have been some proposals to address this problem, but
I am not sure what progress has been made.
We are working on a solution where we can use job-states in the start on
Start/stop on event_a and state_b
Example: start on started job6 and state-running job7
stop on stopped job 6 and state-idle job7
Will conttribute this back when we are done.
Any ideas/suggestions to improve on this proposal are most welcome.
From: upstart-devel-bounces at lists.ubuntu.com
[mailto:upstart-devel-bounces at lists.ubuntu.com] On Behalf Of Kees
Sent: Friday, January 30, 2009 3:13 AM
To: upstart-devel at lists.ubuntu.com
Subject: Implementing a state machine in upstart (0.5)
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
upstart-devel mailing list
upstart-devel at lists.ubuntu.com
Modify settings or unsubscribe at:
More information about the upstart-devel