unconditionally restart trigger services on liminix-rebuild

We call s6-rc -u -p default to restart/start the base services
on a rebuild, otherwise services that are only in the new
configuration won't come up. However, this stops any service
started by a trigger. So, workaround is to restart the trigger
service and expect it to restart the services it manages if they're
needed
This commit is contained in:
Daniel Barlow 2024-04-03 23:07:56 +01:00
parent a192f08881
commit 4795dd05b7
5 changed files with 16 additions and 5 deletions

View file

@ -9,6 +9,7 @@ let
in longrun { in longrun {
name = "ifwait.${interface.name}"; name = "ifwait.${interface.name}";
buildInputs = [ service ]; buildInputs = [ service ];
isTrigger = true;
run = '' run = ''
${ifwait}/bin/ifwait -s ${service.name} $(output ${interface} ifname) ${state} ${ifwait}/bin/ifwait -s ${service.name} $(output ${interface} ifname) ${state}
''; '';

View file

@ -11,7 +11,7 @@ test -n "$contents" && for d in $contents; do
touch $out/${name}/contents.d/$d touch $out/${name}/contents.d/$d
done done
for i in timeout-up timeout-down run notification-fd up down consumer-for producer-for pipeline-name ; do for i in timeout-up timeout-down run notification-fd up down consumer-for producer-for pipeline-name restart-on-upgrade; do
test -n "$(printenv $i)" && (echo "$(printenv $i)" > $out/${name}/$i) test -n "$(printenv $i)" && (echo "$(printenv $i)" > $out/${name}/$i)
done done

View file

@ -36,12 +36,14 @@ let
, dependencies ? [] , dependencies ? []
, contents ? [] , contents ? []
, buildInputs ? [] , buildInputs ? []
, isTrigger ? false
} @ args: } @ args:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
# we use stdenvNoCC to avoid generating derivations with names # we use stdenvNoCC to avoid generating derivations with names
# like foo.service-mips-linux-musl # like foo.service-mips-linux-musl
inherit name serviceType up down run notification-fd inherit name serviceType up down run notification-fd
producer-for consumer-for pipeline-name timeout-up timeout-down; producer-for consumer-for pipeline-name timeout-up timeout-down;
restart-on-upgrade = isTrigger;
buildInputs = buildInputs ++ dependencies ++ contents; buildInputs = buildInputs ++ dependencies ++ contents;
dependencies = builtins.map (d: d.name) dependencies; dependencies = builtins.map (d: d.name) dependencies;
contents = builtins.map (d: d.name) contents; contents = builtins.map (d: d.name) contents;

View file

@ -21,11 +21,16 @@ in stdenvNoCC.mkDerivation {
if test -d $i; then if test -d $i; then
for j in $i/* ; do for j in $i/* ; do
if test -f $j/type ; then if test -f $j/type ; then
if test -e $j/restart-on-upgrade; then
flag=force-restart
else
unset flag
fi
case $(cat $j/type) in case $(cat $j/type) in
longrun|oneshot) longrun|oneshot)
# s6-rc-update only wants oneshots in its # s6-rc-update only wants atomics in its
# restarts file # restarts file
echo $(basename $j) " " $i >> $out/hashes echo $(basename $j) " " ''${flag-$i} >> $out/hashes
;; ;;
*) *)
;; ;;

View file

@ -12,8 +12,11 @@
new-hashes (hashes-from-file new)] new-hashes (hashes-from-file new)]
(with-open [f (io.open "/tmp/restarts" :w)] (with-open [f (io.open "/tmp/restarts" :w)]
(each [n h (pairs old-hashes)] (each [n h (pairs old-hashes)]
(when (not (= h (. new-hashes n))) (let [new (. new-hashes n)]
(f:write (.. n " restart\n"))))))) (when (or (= h "force-restart")
(= new "force-restart")
(not (= h new)))
(f:write (.. n " restart\n"))))))))
(fn exec [text command] (fn exec [text command]
(io.write (.. text ": ")) (io.write (.. text ": "))