From 8d8bf00a34b6b352ef1ae463a277830a4b3721df Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 7 May 2024 15:24:14 +0000 Subject: [PATCH] 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 --- modules/users/s6-rc.nix | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/users/s6-rc.nix b/modules/users/s6-rc.nix index 1a69c61f..070a3362 100644 --- a/modules/users/s6-rc.nix +++ b/modules/users/s6-rc.nix @@ -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;