diff --git a/ssm b/ssm index 3610c65..7843e0b 100755 --- a/ssm +++ b/ssm @@ -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. diff --git a/ssm.conf b/ssm.conf index 3f9757f..41a67c4 100644 --- a/ssm.conf +++ b/ssm.conf @@ -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