s6-rc: use s6-rc stop instead of exiting 125 in the no-restart branch of "restartCondition = on-failure"

exiting 125 stops the service, but does NOT put it in the down state, preventing it from being re-started
This commit is contained in:
Colin 2024-05-07 15:24:14 +00:00
parent f58bcb4767
commit 8d8bf00a34

View File

@ -251,19 +251,14 @@ let
down = maybe (type == "oneshot") service.cleanupCommand;
finish = maybe (type == "longrun") (concatNonNullLines [
service.cleanupCommand
(
if service.restartCondition == "always" then null
else if service.restartCondition == "on-failure" then ''
if [ $1 -eq 0 ]; then
# `man s6-service-directory` says to exit 125 to indicate "permanent failure" equivalent to `s6-svc -O`.
# i do this with the opposite intent though, trying to indicate "permanent success"...
printf "service exited 0: not restarting\n"
exit 125
else
printf "service exited non-zero: restarting (code: %d)\n" "$1"
fi
'' else throw "unknown service.restartCondition '${service.restartCondition}'"
)
(maybe (service.restartCondition == "on-failure") ''
if [ "$1" -eq 0 ]; then
printf "service exited 0: not restarting\n"
s6-rc stop "$3"
else
printf "service exited non-zero: restarting (code: %d)\n" "$1"
fi
'')
]);
run = service.command;
up = service.startCommand;