+#service_cgroup_cleanup
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
8ae151b601
commit
7e0df4a559
19
ssm
19
ssm
|
@ -133,8 +133,8 @@ spawn() {
|
|||
|
||||
## Run the command and wait for it to die
|
||||
svc() {
|
||||
declare job_pid job_exit job_success last_respawn fail_counter date counter
|
||||
var job_pid job_exit job_success last_respawn fail_counter date counter
|
||||
declare job_pid job_exit job_success last_respawn fail_counter date counter p
|
||||
var job_pid job_exit job_success last_respawn fail_counter date counter p
|
||||
|
||||
svc::cleanup() {
|
||||
nullexec kill -n "$service_stop_signal" "$job_pid"
|
||||
|
@ -142,6 +142,20 @@ svc() {
|
|||
anywait "$job_pid" "$service_stop_timeout"
|
||||
rm -f "$svc_pidfile" "$service_ready_flag"
|
||||
|
||||
# Cgroup stuff
|
||||
if cgroups; then
|
||||
if service_cgroup_cleanup; then
|
||||
for p in "${service_cgroup_procs[@]}"; do
|
||||
p == "$BASHPID" || {
|
||||
nullexec kill -n "$service_cgroup_kill_signal" "$p"
|
||||
anywait "$p" "$service_stop_timeout" &
|
||||
}
|
||||
done
|
||||
|
||||
wait || die $?
|
||||
fi
|
||||
fi
|
||||
|
||||
die 0
|
||||
}; trap 'svc::cleanup' TERM
|
||||
|
||||
|
@ -564,6 +578,7 @@ var service_cgroup_wait = 0 # Wait on all the members of the cgroup to exit when
|
|||
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_cgroup_cleanup = 0 # Clean up the cgroup when the main PID exits. Uses service_cgroup_kill_signal.
|
||||
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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user