440caeb555
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
84 lines
2.5 KiB
Text
84 lines
2.5 KiB
Text
cinit - braindumps - shutdown
|
|
=============================
|
|
Nico Schottelius <nico-cinit@@@@schottelius.org>
|
|
v0.1, for cinit-0.3, 2007-01-11
|
|
:Author Initials: NS
|
|
|
|
Just some braindumps. Do not read.
|
|
|
|
Introduction
|
|
------------
|
|
Shutting down the system.
|
|
|
|
When?
|
|
-----
|
|
- reboot
|
|
- halt
|
|
- power off
|
|
- further needed?
|
|
|
|
How / What?
|
|
------------
|
|
- Stop services in the correct order
|
|
* reuse the service tree / needs / needed_by!
|
|
* call off, if existent
|
|
* if respawning, send SIGTERM?
|
|
- not if off is existent?
|
|
* give some variables to off?
|
|
- $RESPAWN_PID: if respawning
|
|
- send SIGTERM to other apps?
|
|
* or put that into special? special/post_svc_shutdown
|
|
- call special/{halt,poweroff,reboot}
|
|
* no, implemented that directly into cinit!
|
|
- implement timely controlled shutdown:
|
|
* cinit.shutdown forks (?) itself and waits, then sends a signal
|
|
to cinit to initiate the shutdown process
|
|
* create mappers for target OS
|
|
- Linux
|
|
- {free,net,open}bsd
|
|
- others may contribute theirself
|
|
- also implement poweroff
|
|
* kill -TERM 1
|
|
- also implement reboot
|
|
* kill -HUP 1
|
|
- also implement halt
|
|
* kill -USR1 1
|
|
|
|
|
|
The implementation
|
|
-----------------
|
|
x shutdown is initiated
|
|
x disable communication (nobody can influence us anymore)
|
|
x install special signal handler?
|
|
- no. we do not care about zombies anymore, we are gone soon anyway
|
|
- simply reset to the default
|
|
- begin to shutdown services
|
|
* where to start?
|
|
* begin shutdown at the end of the tree, viewing/sorting it by the 'needed_by'
|
|
-> where to begin sort?
|
|
-> worst implementation: scan all services (easy for now)
|
|
-> result: list of services, that noone needs :-)
|
|
* stop those services and step above
|
|
- stop a service, as soon as noone needs it anymore
|
|
* check all needed_by links
|
|
* more or less the inverted gen_svc_tree
|
|
- how to shutdown a service
|
|
* if existing, call off
|
|
- if off does not exist:
|
|
* if respawn: send sigterm to the process
|
|
* also implement sigkill at this stage?
|
|
- think we can delay it to the end
|
|
- otherwise users can use off!
|
|
- implement environment for off ($cinit_respawn_pid, $cinit_service_name)
|
|
- do *NOT* care about the return value, we can't do anything for it
|
|
anymore anyway
|
|
- after all services are shutdown, kill all remaining services
|
|
* SIGTERM
|
|
* wait(defined_time_in_seconds)
|
|
* SIGKILL
|
|
- call the last command
|
|
* to cleanup the system
|
|
- umount -a (if needed)
|
|
- swapoff (if needed)
|
|
- sync (if needed)
|
|
- switch off
|