diff --git a/docs/application-deployment.md b/docs/application-deployment.md index 74a079a9868..24323f412ae 100644 --- a/docs/application-deployment.md +++ b/docs/application-deployment.md @@ -123,11 +123,11 @@ This is in particular useful, then you want to deploy to root domain, as # Zero downtime deploy -Following a deploy Dokku's default behaviour is to switch new traffic over to the new container immediately. +Following a deploy, dokku will now wait `DOKKU_DEFAULT_CHECKS_WAIT` seconds (default: `10`), and if the container is still running, then route traffic to the new container. -This can be problematic for applications that take some time to boot up and can lead to `502 Bad Gateway` errors. +This can be problematic for applications whose boot up time can vary and can lead to `502 Bad Gateway` errors. -Dokku provides a way to run a set of checks against the new container, and only switch traffic over if all checks complete successfully. +Dokku provides a way to run a set of more precise checks against the new container, and only switch traffic over if all checks complete successfully. To specify checks, add a `CHECKS` file to the root of your project directory. This is a text file with one line per check. Empty lines and lines starting with `#` are ignored. @@ -137,7 +137,7 @@ A check is a relative URL and may be followed by expected content from the page, /about Our Amazing Team ``` -Dokku will wait `DOKKU_CHECKS_WAIT` seconds (default: `5`) before running the checks to give server time to start. For shorter/longer wait, change the `DOKKU_CHECKS_WAIT` environment variable. This can be overridden in the CHECKS file by setting WAIT=nn. +Dokku will wait `DOKKU_CHECKS_WAIT` seconds (default: `5`) before running the checks to give server time to start. For shorter/longer wait, change the `DOKKU_CHECKS_WAIT` environment variable. This can also be overridden in the CHECKS file by setting WAIT=nn. Dokku will wait `DOKKU_WAIT_TO_RETIRE` seconds (default: `60`) before stopping the old container such that no existing connections to it are dropped. diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index 9a12db51a5d..91b2493a1d0 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -91,9 +91,9 @@ if [[ ! -s "${TMPDIR}/CHECKS" ]] || [[ "$DOKKU_APP_CONTAINER_TYPE" != "web" ]]; # simple default check to see if the container stuck around # for more thorough checks, create a CHECKS file - DOKKU_DEFAULT_WAIT=10 - dokku_log_info1 "Waiting for $DOKKU_DEFAULT_WAIT seconds ..." - sleep $DOKKU_DEFAULT_WAIT + DOKKU_DEFAULT_CHECKS_WAIT="${DOKKU_DEFAULT_CHECKS_WAIT:-10}" + dokku_log_info1 "Waiting for $DOKKU_DEFAULT_CHECKS_WAIT seconds ..." + sleep $DOKKU_DEFAULT_CHECKS_WAIT ! (is_container_running $DOKKU_APP_CONTAINER_ID) && dokku_log_fail "App container failed to start!!" dokku_log_info1 "Default container check successful!" && exit 0