This repository has no description
0

Configure Feed

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

tools.deploy: let tail drain the log instead of killing it

+6 -5
+6 -5
tools/deploy/flake-module.nix
··· 98 98 } 99 99 100 100 # follow <unit>: stream its log until it finishes, fail if it did. 101 + # tail can lag far behind the log when the reader (nom) is slow, so 102 + # it must not be killed on a timer: --pid makes it read the log to 103 + # the end once the waiter (unit finished) is gone, then exit, so 104 + # no line is cut off. 101 105 follow() { 102 106 ssh "''${ssh_opts[@]}" "$target" bash -s -- "$1" "$state" <<'EOF' 103 107 unit=$1 log=$2/$1.log 104 - tail -n +1 -F "$log" 2>/dev/null & 105 - tailpid=$! 106 108 while case $(systemctl show -p ActiveState -p SubState "$unit") in 107 109 *ActiveState=activating* | *SubState=running*) true ;; 108 110 *) false ;; 109 111 esac; do 110 112 sleep 1 111 - done 112 - sleep 1 113 - kill "$tailpid" 113 + done & 114 + tail -n +1 -F --pid=$! "$log" 2>/dev/null 114 115 [ "$(systemctl show -p Result --value "$unit")" = success ] && exit 0 115 116 echo "deploy: $unit failed (exit status $(systemctl show -p ExecMainStatus --value "$unit")), log: $log" >&2 116 117 exit 1