diff --git a/deployments/README.md b/deployments/README.md index 2f4c5ad..18c3ca2 100644 --- a/deployments/README.md +++ b/deployments/README.md @@ -21,6 +21,10 @@ The `port` is mandatory, but the `env_file_path` is optional (for projects that The paths provided in the said file **MUST** be **absolute** (trust me you don't want to handle bash's path spaghetti :upside_down_face: :wink:). +#### Deployment Health Checks and Rollbacks + +You can set a `project_health_check_url` per project, which will be used to assert the service is running properly after deployment. The deploy script will query the url (using cURL) every 10 seconds until it returns HTTP 200, for a maximum of 5 minutes. It is advised that you pass a url served by the respective service which only returns 200 when the service is good operating state. This variable is optional. If it is not provided, the health check will not be done. + ## Notes `docker system prune` should be run periodically to clean up dangling images and containers. The deployment scripts attempt to minimize the number of these but some are left on purpose due to speeding up multi-stage builds. diff --git a/deployments/deploy-types.sh b/deployments/deploy-types.sh index 32a7b41..76acd61 100755 --- a/deployments/deploy-types.sh +++ b/deployments/deploy-types.sh @@ -74,11 +74,13 @@ function deploy_default() { fi local health_check_result - health_check_result=1 + health_check_result=0 if [ $health_check_url ]; then echo -e "Starting health check...\n" - health_checker $health_check_url || true - health_check_result="$?" + # This is done this way due to the use of set -e above. + # If the command is successful, the || won't run, so the default value is 0 + # if the command is not successful, we need the || so that the script does not exit immediately + health_checker $health_check_url || health_check_result="$?" fi if [ "$health_check_result" != 0 ]; then