Merge pull request #8517 from dokku/6833-send-sigterm-immediately-to-old-containers-when-deploying-via-docker-local
Send SIGTERM to old containers immediately on deploy
This commit is contained in:
@@ -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"
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user