init: disable spawning for shutdown
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
upstart |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
It would be very useful to be able to request that Upstart not spawn any new jobs or job instances and also not respawn any existing processes (respawn stanza).
The main use-case scenario for this is shutdown. On Ubuntu, the shutdown is delicate since both Upstart and SystemV jobs have to be handled.
Currently, the script /etc/init.
A solution would appear to be some way to stop Upstart respawning any more processes. A new initctl command such as "initctl disable-spawn" could be introduced to allow existing jobs to finish, but disallow any new jobs or respawns to occur.
Thus,
initctl disable-spawn # stop any new processes from being created by Upstart
Note that if we make this change, we should expose this setting to allow admins to query it. A better interface might therefore be something like this:
initctl set disable-spawn 1 # disable new processes
initctl get # get all variables
initctl get disable-spawn # get value of disable-spawn variable
If we do *this*, maybe we should allow such syntax in /etc/init.conf?
Note that we should probably *not* allow disabling of spawning for individual jobs since:
1) That can already be handled by changing the .conf / .override file
2) If we allowed "initctl disable-spawn <job>" the .conf/.override file would be out-of-date wrt Upstarts internal state for the job.
I think I'm going to do something slightly different here; the only reason to ever disable respawn is in the shutdown procedure, right now that consists of:
* shutdown/telinit sends an event
* user/system upstart jobs process that event
* user/system upstart job finally calls poweroff, halt or reboot
We should turn that on its head to:
* shutdown/telinit sends shutdown command to init
* init sends an event
* user/system upstart jobs process that event
* init kills all remaining jobs
* init sends a second event
* user/system upstart jobs process that event
* init calls the reboot() syscall itself
This will be ultimately much more in pattern with the Upstart way; and that shutdown command would be what disables respawning.
Does this make sense?