Skip to content

Commit

Permalink
feat: adds --wait-after-healthy SECONDS allowing healthy container to…
Browse files Browse the repository at this point in the history
… settle down
  • Loading branch information
benzht committed Mar 12, 2024
1 parent c5d2539 commit 4f246a0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions docker-rollout
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
# Defaults
HEALTHCHECK_TIMEOUT=60
NO_HEALTHCHECK_TIMEOUT=10
WAIT_AFTER_HEALTHY_DELAY=0

# Print metadata for Docker CLI plugin
if [ "$1" = "docker-cli-plugin-metadata" ]; then
Expand Down Expand Up @@ -48,12 +49,14 @@ Usage: docker rollout [OPTIONS] SERVICE
Rollout new Compose service version.
Options:
-h, --help Print usage
-f, --file FILE Compose configuration files
-t, --timeout N Healthcheck timeout (default: $HEALTHCHECK_TIMEOUT seconds)
-w, --wait N When no healthcheck is defined, wait for N seconds
before stopping old container (default: $NO_HEALTHCHECK_TIMEOUT seconds)
--env-file FILE Specify an alternate environment file
-h, --help Print usage
-f, --file FILE Compose configuration files
-t, --timeout N Healthcheck timeout (default: $HEALTHCHECK_TIMEOUT seconds)
-w, --wait N When no healthcheck is defined, wait for N seconds
before stopping old container (default: $NO_HEALTHCHECK_TIMEOUT seconds)
--wait-after-healthy N When healthcheck is defined and succeeds, wait for additional N seconds
before stopping the old container (default: 0 seconds)
--env-file FILE Specify an alternate environment file
EOF
}
Expand Down Expand Up @@ -128,6 +131,9 @@ main() {
docker $DOCKER_ARGS rm $NEW_CONTAINER_IDS

exit 1
elif [ "$WAIT_AFTER_HEALTHY_DELAY" != "0" ]; then
echo "==> Waiting for healthy containers to settle down ($WAIT_AFTER_HEALTHY_DELAY seconds)"
sleep $WAIT_AFTER_HEALTHY_DELAY
fi
else
echo "==> Waiting for new containers to be ready ($NO_HEALTHCHECK_TIMEOUT seconds)"
Expand Down Expand Up @@ -164,6 +170,10 @@ while [ $# -gt 0 ]; do
NO_HEALTHCHECK_TIMEOUT="$2"
shift 2
;;
--wait-after-healthy)
WAIT_AFTER_HEALTHY_DELAY="$2"
shift 2
;;
-*)
echo "Unknown option: $1"
exit_with_usage
Expand Down

0 comments on commit 4f246a0

Please sign in to comment.