Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Fix (set -e) workaround when calling health checker
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotteixeira committed Feb 19, 2022
1 parent 533af9b commit c5691de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions deployments/deploy-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5691de

Please sign in to comment.