Make the thing back off if it restarts too fast even if it doesn't fail

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2026-11-29 13:20:19 +00:00
parent 9c6eea99bf
commit c7264a737e
+5 -5
View File
@@ -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