commit 471c63b3998ab626abd80064b7961495fce9d6e3
parent 782feaeafa343c3e426e289c350d2699f3afe658
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 13 May 2024 17:45:07 +0100
s6-rc do cleanup in "finish", don't append to "run" script
s6-supervise sends signals (e.g. SIGTERM) to the pid of the process
running "run", so how do we know if the ceanup commands are even
getting executed if the shell interpreter that is supposed to do that
got killed already?
Diffstat:
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/pkgs/liminix-tools/services/builder.sh b/pkgs/liminix-tools/services/builder.sh
@@ -11,7 +11,7 @@ test -n "$contents" && for d in $contents; do
touch $out/${name}/contents.d/$d
done
-for i in timeout-up timeout-down run notification-fd up down consumer-for producer-for pipeline-name restart-on-upgrade; do
+for i in timeout-up timeout-down run notification-fd up down finish consumer-for producer-for pipeline-name restart-on-upgrade; do
test -n "$(printenv $i)" && (echo "$(printenv $i)" > $out/${name}/$i)
done
diff --git a/pkgs/liminix-tools/services/default.nix b/pkgs/liminix-tools/services/default.nix
@@ -18,6 +18,7 @@ let
${commands}
'';
cleanupScript = name : ''
+ #!/bin/sh
if test -d ${prefix}/${name} ; then rm -rf ${prefix}/${name} ; fi
'';
service = {
@@ -26,6 +27,7 @@ let
, run ? null
, up ? null
, down ? null
+ , finish ? null
, outputs ? []
, notification-fd ? null
, producer-for ? null
@@ -41,7 +43,7 @@ let
stdenvNoCC.mkDerivation {
# we use stdenvNoCC to avoid generating derivations with names
# like foo.service-mips-linux-musl
- inherit name serviceType up down run notification-fd
+ inherit name serviceType up down run finish notification-fd
producer-for consumer-for pipeline-name timeout-up timeout-down;
restart-on-upgrade = isTrigger;
buildInputs = buildInputs ++ dependencies ++ contents;
@@ -70,7 +72,8 @@ let
in service (args // {
buildInputs = buildInputs ++ [ logger ];
serviceType = "longrun";
- run = serviceScript "${run}\n${cleanupScript name}";
+ run = serviceScript run;
+ finish = cleanupScript name;
producer-for = "${name}-log";
});