Skip to content

Commit

Permalink
Health check added back on workers startup, before adding their IP on…
Browse files Browse the repository at this point in the history
… consul.
  • Loading branch information
ThanKarab committed Jan 21, 2021
1 parent aff0399 commit c29b5ed
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Exareme-Docker/files/root/exareme/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ exaremeNodesHealthCheck() {
return 0
}

# Exareme health check on startup
startupExaremeNodesHealthCheck() {
# If health check fails then try again until it succeeds or close the container.
attempts=0
while ! exaremeNodesHealthCheck; do
if [[ $attempts -ge $EXAREME_NODE_STARTUP_HEALTH_CHECK_MAX_ATTEMPTS ]]; then
echo -e "\n$(timestamp) HEALTH CHECK FAILED. Closing the container."
return 1 # Exiting
fi
echo "$(timestamp) HEALTH CHECK failed. Trying again..."
attempts=$(($attempts + 1))
sleep $EXAREME_HEALTH_CHECK_AWAIT_TIME
done
echo "$(timestamp) HEALTH CHECK successful on NODE_IP: $NODE_IP"
return 0
}

# Periodic check for exareme's health.
# If it fails shutdown the container
periodicExaremeNodesHealthCheck() {
Expand Down Expand Up @@ -249,6 +266,11 @@ else ##### Running bootstrap on a worker node #####

echo "$(timestamp) Starting Exareme on worker node with IP: ${NODE_IP} and nodeName: ${NODE_NAME}"
. ./start-worker.sh

if ! startupExaremeNodesHealthCheck; then
echo "$(timestamp) HEALTH CHECK algorithm failed. Switch ENVIRONMENT_TYPE to 'DEV' to see error messages coming from EXAREME. Exiting..."
exit 1
fi

# Updating consul with node IP
echo -e "\n$(timestamp) Updating consul with worker node IP."
Expand Down

0 comments on commit c29b5ed

Please sign in to comment.