diff --git a/ssm b/ssm index a860acf..3610c65 100755 --- a/ssm +++ b/ssm @@ -151,18 +151,18 @@ svc() { printf '%s' $BASHPID > "$svc_pidfile" + # Cgroups + if cgroups; then + mkdir -p "$cgroup_home/$service_cgroup_name" + echo "$BASHPID" > "$cgroup_home/$service_cgroup_name/cgroup.procs" + fi + while true; do job_success = 0 # Needs to be reset # Spawn the process and record the PID spawn "$@" & job_pid = "$!" - # Cgroups - if cgroups; then - mkdir -p "$cgroup_home/$service_cgroup_name" - echo "$job_pid" > "$cgroup_home/$service_cgroup_name/cgroup.procs" - fi - # Wait for the process to exit and record the exit code # This depends on a few things if service_managed; then @@ -552,12 +552,12 @@ var service_reload_signal = 1 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_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. # Global config var cgroups = 0 # Enable cgroup-related functions -var cgroups_check_pid = 1 # Enable checking if the main service PID is in the correct cgroup before doing anythin with the service var usrdir = '/usr/share/ssm' # These are not @@ -748,7 +748,7 @@ if cgroups; then fi # If there's a service PID, check if it's in the service's cgroup - if cgroups_check_pid; then + if service_cgroup_strict; then if service_pid; then service_cgroup_procs u "$service_pid" || die 29 "Recorded service PID is not in the service's cgroup, bailing!" fi diff --git a/ssm.conf b/ssm.conf index b1fd560..3f9757f 100644 --- a/ssm.conf +++ b/ssm.conf @@ -1,41 +1,44 @@ # This is actually a bash script +# Enable cgroup-related functions +#cgroups = 0 + # Where to search for services, works as a PATH-like array. #service_path = "$XDG_CONFIG_HOME/ssm/services" /etc/ssm/services "$rundir/services" /usr/share/ssm/services # Service defaults -# Respawn the service if it exits + +## Respawn the service if it exits #service_respawn = 0 -# Working directory +## Working directory #service_workdir = '/' -# How long do we wait for the service to stop +## How long do we wait for the service to stop #service_stop_timeout = 30 -# How long do we wait for the service to get ready +## How long do we wait for the service to get ready #service_ready_timeout = 15 -# Signals to pass through to the service under the respawner +## Signals to pass through to the service under the respawner #service_signals = 1 10 12 -# The signal to send to reload the service +## The signal to send to reload the service #service_reload_signal = 1 -# The signal to send to stop the service +## The signal to send to stop the service #service_stop_signal = 15 -# Enable cgroup-related functions -#cgroups = 0 +## These only work with cgroups = 1: -# Check if the recorded PID of the service is in the correct cgroup. -# Only works with cgroups = 1 -#cgroups_check_pid = 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 +## 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 +## Wait on all the members of the cgroup to exit when stopping the service. +## Only works with cgroups = 1 #service_cgroup_wait = 0