From d50b66fe76ea0dceb90d8b1876bcd2826e6d1ca6 Mon Sep 17 00:00:00 2001 From: Tobias Kussel Date: Fri, 9 Oct 2026 11:22:48 +0200 Subject: [PATCH] Guard against conflicts in Systemd's shutdown orchestration --- bridgehead | 5 +++++ lib/systemd/bridgehead@.service | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bridgehead b/bridgehead index 58bb92b..abec18f 100755 --- a/bridgehead +++ b/bridgehead @@ -127,6 +127,11 @@ case "$ACTION" in exec $COMPOSE -p $PROJECT -f ./minimal/docker-compose.yml -f ./$PROJECT/docker-compose.yml $OVERRIDE up --abort-on-container-exit ;; stop) + # INVOCATION_ID is set by Systemd, so manual commands and Systemd's orchestration does not interfer + if [ -z "${INVOCATION_ID:-}" ] && systemctl is-active --quiet "bridgehead@$PROJECT"; then + log ERROR "bridgehead@$PROJECT is managed by systemd. Stop it with: sudo systemctl stop bridgehead@$PROJECT" + exit 1 + fi loadVars # Kill stale secret-sync instances if present docker kill $(docker ps -q --filter ancestor=docker.verbis.dkfz.de/cache/samply/secret-sync-local) 2>/dev/null || true diff --git a/lib/systemd/bridgehead@.service b/lib/systemd/bridgehead@.service index 7645793..19cb0a7 100644 --- a/lib/systemd/bridgehead@.service +++ b/lib/systemd/bridgehead@.service @@ -8,7 +8,10 @@ Restart=always RestartSec=30 ExecStartPre=-/srv/docker/bridgehead/bridgehead preRun %i ExecStart=/srv/docker/bridgehead/bridgehead start %i -ExecStop=/srv/docker/bridgehead/bridgehead stop %i +SuccessExitStatus=130 +TimeoutStopSec=120 +# Clean up containers after stop +ExecStopPost=-/srv/docker/bridgehead/bridgehead stop %i ExecStopPost=-/srv/docker/bridgehead/bridgehead postRun %i [Install]