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