feat: send SIGTERM to old containers immediately on deploy

The docker-local scheduler now sends `SIGTERM` to old containers immediately after a successful deploy via `docker container kill --signal=SIGTERM`, rather than waiting `wait-to-retire` seconds before signaling. This matches Heroku's graceful-shutdown contract and lets applications begin draining in-flight work as soon as proxy traffic switches. The existing `wait-to-retire` grace period and `stop-timeout-seconds` hard-stop continue to apply unchanged as the authoritative cleanup path.
This commit is contained in:
Jose Diaz-Gonzalez
2026-04-27 18:18:39 -04:00
parent f19227dcd9
commit 1161dda05e
4 changed files with 55 additions and 1 deletions

View File

@@ -84,6 +84,19 @@ trigger-scheduler-docker-local-scheduler-deploy() {
# kill the old container
if [[ -n "$oldids" ]]; then
# Send SIGTERM to old containers immediately so the application can begin
# graceful shutdown the moment proxy traffic switches to the new containers.
# We use `container kill --signal=SIGTERM` rather than `container stop`
# because it returns immediately and docker does not follow up with a
# SIGKILL on its own when the signal is something other than SIGKILL -
# the existing background block below remains responsible for the
# eventual hard stop after the wait-to-retire grace period.
for oldid in $oldids; do
if "$DOCKER_BIN" container inspect "$oldid" &>/dev/null; then
"$DOCKER_BIN" container kill --signal=SIGTERM "$oldid" &>/dev/null || true
fi
done
# Let the old container finish processing requests, before terminating it
dokku_log_info1 "Shutting down old containers in $DOKKU_WAIT_TO_RETIRE seconds"
(