'system' state: an elegant way to handle shutdown?
Johan Kiviniemi
upstart-devel-list at johan.kiviniemi.name
Wed Oct 14 22:13:55 BST 2009
Hi,
The following was discussed on IRC; I’ll paste the log at the end.
An (implicit?) ‘system’ job/state could provide an elegant way to
handle shutdown. Any job that should be started on system startup and
requires some action just before halt/reboot would have ‘while system’
and possible pre/post-stop scripts.
To reboot, one could run ‘stop system SHUTDOWN_ACTION=reboot’;
system.conf could then consist of
post-stop script
if [ "$SHUTDOWN_ACTION" = reboot ]; then
reboot -f
else
halt -f
fi
end script
which would be called after anything depending on the system state has
been stopped first.
The relevant parts of the log:
2009-10-14 21:31:00 < ion> Misc. rambling: instead of a ‘startup’
event, 0.10 should have a ‘system’ state. Instead of ‘start on
startup’, jobs would have ‘while system’. Shutdown/reboot would happen
by running ‘stop system ACTION=reboot’; all ‘while system’ jobs would
stop and there would be a halt.conf job that looks something like
‘around system’, ‘post-stop exec if [ "$SHUTDOWN_ACTION" = reboot ];
then reboot -f; else halt -f; fi’.
2009-10-14 21:31:38 < sadmac> ion: there's neither. to start on
startup you just don't put any while or on stanzas
2009-10-14 21:32:04 < sadmac> ion: a job with no on stanzas starts a
soon as its conditions are met.
2009-10-14 21:32:08 < ion> How about if you only want to start a job manually?
2009-10-14 21:32:55 < sadmac> ion: you set the job in manual mode via
a separate configuration file.
2009-10-14 21:33:12 < ion> A ‘system’ state would be an elegant
solution for halting IMO. :-P
2009-10-14 21:35:05 < sadmac> ion: maybe
2009-10-14 21:36:17 < sadmac> ion: its actually a nice addition to the
current mechanism. All your crash-only jobs that don't need to be
killed before cutting the power can just omit the while system stanza
2009-10-14 21:36:35 < sadmac> ion: so "while system" is how a job
indicates its sensitive to sudden power evaporation
2009-10-14 21:38:06 < ion> True, true
2009-10-14 21:49:41 < ion> In fact, Upstart wouldn’t really need to
treat the system state in a special way, there could simply be an
empty /etc/init/system.conf that comes with the package. People would
just be told to point to that for anything that requires some action
before halting the system.
2009-10-14 21:55:16 < sadmac> ion: maybe. There could be advantages to
internalizing it too, since it starts so friggin early
2009-10-14 21:55:51 < sadmac> ion: an idea: suppose upstart ran from initrd
2009-10-14 21:56:24 < sadmac> ion: system pre-start becomes the core
script of dracut as it is now. when system itself starts, upstart
re-execs on the new root.
2009-10-15 00:07:45 < ion> The filesystem state could have ‘while
system and stuff’ and anything that needs to close files would have
‘while filesystem’. stop system → anything depending on filesystem
would stop, the filesystem job would stop (handle unmounts etc. here),
the system job would stop, the halt job would stop (and shutdown the
system).
Regards,
--
Jοhan Kiviniemi http://johan.kiviniemi.name/
More information about the upstart-devel
mailing list