When a service is started through an init script, a file is touched in the
When the service is stopped,this file is removed.This file represents that a service's subsystem is locked,which means the service should be running. Since a service may consist of multiple executables with different names, finding the process ID (PID) of a single executable may not be sufficient to determine the status of the entire service itself.
For this reason, the command:
I.If the service does not lock the subsystem, it can still be started and stopped through the service interface. However, when switching runlevels, the rc scripts check for the existence of the file in
If this file is not found, the service will not correctly start or stop between runlevels, even if there are start and kill symbolic links in the
II.
The order of a shutdown is as follows:
This attempts to stop the service gracefully before handing off to steps 2 through 4, which forcefully terminate the process itself.
/var/lock/subsys/
directory with the same name as the init script. When the service is stopped,this file is removed.This file represents that a service's subsystem is locked,which means the service should be running. Since a service may consist of multiple executables with different names, finding the process ID (PID) of a single executable may not be sufficient to determine the status of the entire service itself.
For this reason, the command:
service "initscript" status
checks both the PID of the executable and the file in the /var/lock/subsys/
directory. If the PID is not found but the subsystem is locked, you will receive a message similar to this:
"service" dead but subsys locked
Managing a service's subsystem has two purposes. I.If the service does not lock the subsystem, it can still be started and stopped through the service interface. However, when switching runlevels, the rc scripts check for the existence of the file in
/var/lock/subsys/
.If this file is not found, the service will not correctly start or stop between runlevels, even if there are start and kill symbolic links in the
/etc/rc#.d/
directories.II.
/var/lock/subsys/
directory is checked during reboots and shutdowns. The order of a shutdown is as follows:
- Run
service "initscript" stop
for all known services - Run
kill -SIGTERM
to terminate all processes - Pause for five seconds
- Run
kill -SIGKILL
to kill all remaining processes
/etc/rc.d/init.d/killall
checks the /var/lock/subsys/
directory to see if any subsystems are still locked. If a service's subsystem is locked after all other services have been stopped (i.e.step 1 above has completed), the killall
script uses the subsystem filename to call service "initscript" stop
.This attempts to stop the service gracefully before handing off to steps 2 through 4, which forcefully terminate the process itself.
No comments:
Post a Comment