how does system-config-services know the correct order for service startup ?
Is it taken from a simple text file?
Is it hardcoded into the binary?
Is it from rand()?
Is it based on the position of Jupiter in relation to Saturn?
It's a small curiosity I for which I would like an answer.
Yes, this could also fit into the RedHat and Fedora forums.
-J Tom Moon
Iff you look in /etc, you will find several subdirectories and configuration files. One of these directories contains the startup scripts for all of the system services (/etc/init.d). The order in which these scripts is executed is a semi-complex operation beginning within each one of these scripts. If you look at one of these scripts, near the top wil be a line as follows:
# chkconfig: 35 91 9
This is read by a script called "chkconfig". chkconfig can add a script to the runtime directories (/etc/rc[1-5].d) in the correct order of execution. If you look at /etc/rc5.d, you will notice several sympolic links that start with either an S or a K, followed by two numbers and the name of the service. When the init process is booting up, it first determines which runlevel to start in by reading the /etc/inittab file, then executing each script in order. The K, means to kill a service when entering this runlevel, an S means to start the service.
The numbers give each service an order of precidence. For example, you don't want your system running the file or web server services before the network has started. You also don't want the network to start before the system has had a chance to discover if there is a new network card or other hardware that needs configuring. Currently, each service waits for the previous service to finish initializing (pass or fail, they still wait). Work is currently under way for processes to be brought up in parallel, which would greatly spead up the Linux boot process. Things like the background virus scanning software (clamav) could be started while waiting for the network to retrieve an ip address, or the XWindows system could be started while wating for the print services to initialize.
Basically, the Linux kernel starts the "init" program (process ID "1"), "init" executes the stuff listed in "/etc/inittab" (depending on which "run level" states it passes through), and each "run level" invokes zero or more startup or shutdown scripts located in /etc/rc.d/rcX.d (where "X" is run level 0, 1, 2, 3, 4, 5 or 6). The scripts are run consecutively, in alphabetic order.
For example, these are the scripts run for "init 3" (run level 3 == multi-user, text mode):
Here's a link that explains further:
I was typing my (long-winded!) explanation at the same time as GrueMaster. We're both saying the same thing - apologies for any duplicate redundancy ;-)
|All times are GMT -5. The time now is 06:10 AM.|