3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 07:05:44 +01:00

Stop a leg's container on Ctrl-C with docker run --init

This commit is contained in:
2026-11-08 23:00:22 +01:00
committed by Lillem4n
parent b3d136da7b
commit 058533752e
4 changed files with 31 additions and 8 deletions
+20
View File
@@ -45,6 +45,26 @@ boundaries_fire() {
leg "import boundaries fire ($node_image)" boundaries_fire
# Without `docker run --init`, process 1 ignores the SIGINT docker forwards and the container runs to its end.
interrupt_stops_container() {
local pid ready started waited=0
ready=$(mktemp) || return 1
in_image "$node_image" sh -c 'echo ready; sleep 60' > "$ready" &
pid=$!
until grep -q ready "$ready"; do
waited=$((waited + 1))
[ "$waited" -le 300 ] || return 1
sleep 0.2
done
kill -INT "$pid"
started=$SECONDS
wait "$pid" || true
rm -f "$ready"
[ $((SECONDS - started)) -lt 20 ]
}
leg "Ctrl-C stops a leg's container ($node_image)" interrupt_stops_container
test_log=$(mktemp)
node_tests() {
in_image "$node_image" npm test 2>&1 | tee "$test_log"