From c7264a737e119a98c83761b0f16d9b054fbefacf Mon Sep 17 00:00:00 2001 From: fbt Date: Sun, 29 Nov 2026 13:20:19 +0000 Subject: [PATCH] Make the thing back off if it restarts too fast even if it doesn't fail Signed-off-by: fbt --- ssm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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