This seems to work fine

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2026-11-29 09:43:29 +00:00
parent d07c8473f5
commit cd87cb46cd
+9 -6
View File
@@ -164,6 +164,8 @@ svc() {
declare job_pid job_exit job_success last_respawn fail_counter date counter p 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 var job_pid job_exit job_success last_respawn fail_counter date counter p
job_exit = 0 # Exit successfully by default
svc::cleanup() { svc::cleanup() {
#nullexec kill -n "$service_stop_signal" "$job_pid" #nullexec kill -n "$service_stop_signal" "$job_pid"
nullexec "${service_stop_command[@]}" nullexec "${service_stop_command[@]}"
@@ -192,6 +194,10 @@ svc() {
rm -f "$svc_pidfile" "$service_pidfile" "$service_ready_flag" rm -f "$svc_pidfile" "$service_pidfile" "$service_ready_flag"
# Record the job exit code
printf '%d' "$job_exit" > "$service_exit_file"
# Die
die "$job_exit" die "$job_exit"
}; trap 'svc::cleanup' TERM }; trap 'svc::cleanup' TERM
@@ -228,7 +234,7 @@ svc() {
until service_pidfile is file; do until service_pidfile is file; do
(( counter >= service_pidfile_timeout*10 )) && { (( counter >= service_pidfile_timeout*10 )) && {
printf 'Timed out waiting for pidfile: %s' "$service_pidfile" >&2 printf 'Timed out waiting for pidfile: %s' "$service_pidfile" >&2
printf '127' > "$service_exit_file" job_exit=127
break break
} }
counter++ counter++
@@ -241,14 +247,14 @@ svc() {
# Fail if the pid is empty # Fail if the pid is empty
[[ $job_pid ]] || { [[ $job_pid ]] || {
printf 'Job pidfile is empty: %s\n' "$service_pidfile" >&2 printf 'Job pidfile is empty: %s\n' "$service_pidfile" >&2
printf '98' > "$service_exit_file" job_exit=127
break break
} }
# Fail if the pid doesn't look right # Fail if the pid doesn't look right
printf -v _ '%d' "$job_pid" || { printf -v _ '%d' "$job_pid" || {
printf 'Job PID in %s seems to be malformed' "$service_pidfile" >&2 printf 'Job PID in %s seems to be malformed' "$service_pidfile" >&2
printf '99' > "$service_exit_file" job_exit=127
break break
} }
@@ -270,9 +276,6 @@ svc() {
fail_counter++ fail_counter++
fi fi
# Record the exit code
printf '%s' "$job_exit" > "$service_exit_file"
# Back off if the service exits too much AND too quickly. # Back off if the service exits too much AND too quickly.
if ! service_respawn_force; then if ! service_respawn_force; then
if (( fail_counter >= 3 )); then if (( fail_counter >= 3 )); then