A feature to kill the cgroup members when stopping the service

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2018-03-05 01:01:57 +03:00
parent 2f3837d07c
commit 8ae151b601
2 changed files with 17 additions and 4 deletions

13
ssm
View File

@ -414,11 +414,20 @@ stop() {
# Cgroup stuff
if cgroups; then
if service_cgroup_kill; then
service_cgroup_wait = 1
for p in "${service_cgroup_procs[@]}"; do
nullexec kill -n "$service_cgroup_kill_signal" "$p"
done
fi
if service_cgroup_wait; then
for p in "${service_cgroup_procs[@]}"; do
anywait "$p" "$service_stop_timeout" &
wait || return 5
done
wait || return 5
fi
fi
@ -553,6 +562,8 @@ var service_stop_signal = 15
var service_cgroup_exclusive = 0 # Refuse to start the service if its cgroup is not empty
var service_cgroup_wait = 0 # Wait on all the members of the cgroup to exit when stopping the service.
var service_cgroup_strict = 1 # Enable checking if the main service PID is in the correct cgroup before doing anythin with the service
var service_cgroup_kill = 0 # Kill the entire cgroup when stopping the service.
var service_cgroup_kill_signal = 15 # The signal to send to the stray cgroup members.
var service_success_exit = 0 # Array, takes exit codes that are to be treated as successful termination.
var service_pidfile_timeout = 15 # How long to wait for unmanaged services to create their pidfiles.

View File

@ -32,13 +32,15 @@
## These only work with cgroups = 1:
## Check if the recorded PID of the service is in the correct cgroup.
## Only works with cgroups = 1
#service_cgroup_strict = 1
## Refuse to start the service if its cgroup is not empty
## Only works with cgroups = 1
#service_cgroup_exclusive = 0
## Wait on all the members of the cgroup to exit when stopping the service.
## Only works with cgroups = 1
#service_cgroup_wait = 0
## Send a kill signal to the members of cgroup when
## stopping the service, and the signal to send:
#service_cgroup_kill = 0
#service_cgroup_kill_signal = 15