diff --git a/ssm b/ssm index 4709dcb..8e75787 100755 --- a/ssm +++ b/ssm @@ -159,8 +159,8 @@ cgroup_get_procs() { ## Run the command and wait for it to die svc() { - 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 + declare job_pid job_exit job_success last_respawn loop_counter date counter p + var job_pid job_exit job_success last_respawn loop_counter date counter p job_exit = 0 # Exit successfully by default @@ -272,15 +272,15 @@ svc() { # One service failure, two service failures... if service_success_exit u "$job_exit"; then job_success = 1 - (( fail_counter )) && fail_counter=0 else job_success = 0 - fail_counter++ fi + loop_counter++ + # Back off if the service exits too much AND too quickly. if ! service_respawn_force; then - if (( fail_counter >= 3 )); then + if (( loop_counter >= 3 )); then printf -v date '%(%s)T' (( (date - last_respawn) <= 5 )) && break