This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.deploy: retry systemctl while a switch reexecutes systemd

+9 -4
+9 -4
tools/deploy/flake-module.nix
··· 101 101 # tail can lag far behind the log when the reader (nom) is slow, so 102 102 # it must not be killed on a timer: --pid makes it read the log to 103 103 # the end once the waiter (unit finished) is gone, then exit, so 104 - # no line is cut off. 104 + # no line is cut off. systemctl fails for a moment while a switch 105 + # reexecutes systemd ("Failed to connect to system scope bus"); 106 + # that is retried, not taken for the unit having finished. 105 107 follow() { 106 108 ssh "''${ssh_opts[@]}" "$target" bash -s -- "$1" "$state" <<'EOF' 107 109 unit=$1 log=$2/$1.log 108 - while case $(systemctl show -p ActiveState -p SubState "$unit") in 110 + query() { 111 + until systemctl show "$@" "$unit" 2>/dev/null; do sleep 1; done 112 + } 113 + while case $(query -p ActiveState -p SubState) in 109 114 *ActiveState=activating* | *SubState=running*) true ;; 110 115 *) false ;; 111 116 esac; do 112 117 sleep 1 113 118 done & 114 119 tail -n +1 -F --pid=$! "$log" 2>/dev/null 115 - [ "$(systemctl show -p Result --value "$unit")" = success ] && exit 0 116 - echo "deploy: $unit failed (exit status $(systemctl show -p ExecMainStatus --value "$unit")), log: $log" >&2 120 + [ "$(query -p Result --value)" = success ] && exit 0 121 + echo "deploy: $unit failed (exit status $(query -p ExecMainStatus --value)), log: $log" >&2 117 122 exit 1 118 123 EOF 119 124 }