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
|
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.pseudofile) dir symlink;
|
||||||
inherit (pkgs.liminix.networking) interface;
|
inherit (pkgs.liminix.networking) interface;
|
||||||
|
|
|
@ -84,9 +84,6 @@ in rec {
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
down = ''
|
|
||||||
rm -rf /run/service-state/${name}/
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
filesystem = dir {
|
filesystem = dir {
|
||||||
etc = dir {
|
etc = dir {
|
||||||
|
|
|
@ -119,9 +119,6 @@ in rec {
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
down = ''
|
|
||||||
rm -rf /run/service-state/${name}/
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
filesystem = dir {
|
filesystem = dir {
|
||||||
etc = dir {
|
etc = dir {
|
||||||
|
|
|
@ -131,9 +131,6 @@ in rec {
|
||||||
chmod 0444 resolv.conf
|
chmod 0444 resolv.conf
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
down = ''
|
|
||||||
rm -rf /run/service-state/${name}/
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
filesystem =
|
filesystem =
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (builtins) concatStringsSep;
|
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 : ''
|
serviceScript = commands : ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec 2>&1
|
exec 2>&1
|
||||||
. ${serviceFns}
|
. ${serviceFns}
|
||||||
${commands}
|
${commands}
|
||||||
'';
|
'';
|
||||||
|
cleanupScript = name : ''
|
||||||
|
#!/bin/sh
|
||||||
|
test -d ${prefix}/${name} && rm -rf ${prefix}/${name}
|
||||||
|
'';
|
||||||
service = {
|
service = {
|
||||||
name
|
name
|
||||||
, serviceType
|
, serviceType
|
||||||
|
@ -61,21 +66,23 @@ let
|
||||||
in service (args // {
|
in service (args // {
|
||||||
buildInputs = [ logger ];
|
buildInputs = [ logger ];
|
||||||
serviceType = "longrun";
|
serviceType = "longrun";
|
||||||
run = serviceScript run;
|
run = serviceScript "${run}\n${cleanupScript name}";
|
||||||
producer-for = "${name}-log";
|
producer-for = "${name}-log";
|
||||||
});
|
});
|
||||||
|
|
||||||
oneshot = {
|
oneshot = {
|
||||||
name
|
name
|
||||||
, up
|
, up
|
||||||
, down
|
, down ? ""
|
||||||
, outputs ? []
|
, outputs ? []
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
, ...
|
, ...
|
||||||
} @ args : service (args // {
|
} @ args : service (args // {
|
||||||
serviceType = "oneshot";
|
serviceType = "oneshot";
|
||||||
up = writeScript "${name}-up" (serviceScript up);
|
up = writeScript "${name}-up" (serviceScript up);
|
||||||
down= writeScript "${name}-down" (serviceScript down);
|
down = writeScript
|
||||||
|
"${name}-down"
|
||||||
|
"${serviceScript down}\n${cleanupScript name}";
|
||||||
});
|
});
|
||||||
bundle = {
|
bundle = {
|
||||||
name
|
name
|
||||||
|
|
Loading…
Reference in a new issue