remove service-state when service exits
This commit is contained in:
parent
4fd1b5f08b
commit
f7b30939b5
5 changed files with 11 additions and 14 deletions
|
@ -75,7 +75,6 @@
|
|||
dd if=/dev/$part of=data iflag=skip_bytes,fullblock bs=${toString size} skip=${toString offset} count=1
|
||||
)
|
||||
'';
|
||||
down = "true";
|
||||
};
|
||||
inherit (pkgs.pseudofile) dir symlink;
|
||||
inherit (pkgs.liminix.networking) interface;
|
||||
|
|
|
@ -84,9 +84,6 @@ in rec {
|
|||
done
|
||||
)
|
||||
'';
|
||||
down = ''
|
||||
rm -rf /run/service-state/${name}/
|
||||
'';
|
||||
};
|
||||
filesystem = dir {
|
||||
etc = dir {
|
||||
|
|
|
@ -119,9 +119,6 @@ in rec {
|
|||
done
|
||||
)
|
||||
'';
|
||||
down = ''
|
||||
rm -rf /run/service-state/${name}/
|
||||
'';
|
||||
};
|
||||
filesystem = dir {
|
||||
etc = dir {
|
||||
|
|
|
@ -131,9 +131,6 @@ in rec {
|
|||
chmod 0444 resolv.conf
|
||||
)
|
||||
'';
|
||||
down = ''
|
||||
rm -rf /run/service-state/${name}/
|
||||
'';
|
||||
};
|
||||
|
||||
filesystem =
|
||||
|
|
|
@ -9,13 +9,18 @@
|
|||
}:
|
||||
let
|
||||
inherit (builtins) concatStringsSep;
|
||||
output = service: name: "/run/service-state/${service.name}/${name}";
|
||||
prefix = "/run/service-state";
|
||||
output = service: name: "${prefix}/${service.name}/${name}";
|
||||
serviceScript = commands : ''
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
. ${serviceFns}
|
||||
${commands}
|
||||
'';
|
||||
cleanupScript = name : ''
|
||||
#!/bin/sh
|
||||
test -d ${prefix}/${name} && rm -rf ${prefix}/${name}
|
||||
'';
|
||||
service = {
|
||||
name
|
||||
, serviceType
|
||||
|
@ -61,21 +66,23 @@ let
|
|||
in service (args // {
|
||||
buildInputs = [ logger ];
|
||||
serviceType = "longrun";
|
||||
run = serviceScript run;
|
||||
run = serviceScript "${run}\n${cleanupScript name}";
|
||||
producer-for = "${name}-log";
|
||||
});
|
||||
|
||||
oneshot = {
|
||||
name
|
||||
, up
|
||||
, down
|
||||
, down ? ""
|
||||
, outputs ? []
|
||||
, dependencies ? []
|
||||
, ...
|
||||
} @ args : service (args // {
|
||||
serviceType = "oneshot";
|
||||
up = writeScript "${name}-up" (serviceScript up);
|
||||
down= writeScript "${name}-down" (serviceScript down);
|
||||
down = writeScript
|
||||
"${name}-down"
|
||||
"${serviceScript down}\n${cleanupScript name}";
|
||||
});
|
||||
bundle = {
|
||||
name
|
||||
|
|
Loading…
Reference in a new issue