Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate health checks for all the jobs #79

Merged
merged 5 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pattern-2/bosh-release/jobs/apim_health_check/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: apim_health_check

templates:
run.sh: bin/run

packages: []

properties: {}
42 changes: 42 additions & 0 deletions pattern-2/bosh-release/jobs/apim_health_check/templates/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -e

isAlive=0

health_check() {
# Check if health check endpoint is alive
if curl --output /dev/null --silent --fail -k "$1"
then
status_code=$(curl --write-out %{http_code} --silent --output /dev/null -k ${1})

# Check if requests to the health check endpoint produces 200 response
if [[ "$status_code" -ne 200 ]] ; then
>&2 echo "WSO2 APIM $2 produces an invalid response: $status_code"
exit 1
else
echo "WSO2 APIM $2 is Running!"
isAlive=1
fi
else
>&2 echo "WSO2 APIM $2 is not alive. Retrying in 10s..."
isAlive=0
fi
}

carbonHealthCheckEP="https://localhost:9443/carbon/admin/login.jsp"
COUNTER=0

# While the endpoint is not alive, and the server has been retrying for less than 3 minutes
while [ ${isAlive} -eq 0 ]&&[ ${COUNTER} -lt 18 ]; do
sleep 10s
health_check ${carbonHealthCheckEP} pub-store-tm
let COUNTER=COUNTER+1
done

if [ ${isAlive} -eq 0 ]; then
>&2 echo "Could not connect to WSO2 APIM $2. Exiting..."
exit 1
fi

exit 0
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: health_check
name: gw_health_check

templates:
run.sh: bin/run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COUNTER=0
# While the endpoint is not alive, and the server has been retrying for less than 3 minutes
while [ ${isAlive} -eq 0 ]&&[ ${COUNTER} -lt 18 ]; do
sleep 10s
health_check ${carbonHealthCheckEP} Carbon
health_check ${carbonHealthCheckEP} gateway
let COUNTER=COUNTER+1
done

Expand Down
Empty file.
9 changes: 9 additions & 0 deletions pattern-2/bosh-release/jobs/km_health_check/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: km_health_check

templates:
run.sh: bin/run

packages: []

properties: {}
42 changes: 42 additions & 0 deletions pattern-2/bosh-release/jobs/km_health_check/templates/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -e

isAlive=0

health_check() {
# Check if health check endpoint is alive
if curl --output /dev/null --silent --fail -k "$1"
then
status_code=$(curl --write-out %{http_code} --silent --output /dev/null -k ${1})

# Check if requests to the health check endpoint produces 200 response
if [[ "$status_code" -ne 200 ]] ; then
>&2 echo "WSO2 APIM $2 produces an invalid response: $status_code"
exit 1
else
echo "WSO2 APIM $2 is Running!"
isAlive=1
fi
else
>&2 echo "WSO2 APIM $2 is not alive. Retrying in 10s..."
isAlive=0
fi
}

carbonHealthCheckEP="https://localhost:9443/carbon/admin/login.jsp"
COUNTER=0

# While the endpoint is not alive, and the server has been retrying for less than 3 minutes
while [ ${isAlive} -eq 0 ]&&[ ${COUNTER} -lt 18 ]; do
sleep 10s
health_check ${carbonHealthCheckEP} keymanager
let COUNTER=COUNTER+1
done

if [ ${isAlive} -eq 0 ]; then
>&2 echo "Could not connect to WSO2 APIM $2. Exiting..."
exit 1
fi

exit 0
6 changes: 3 additions & 3 deletions pattern-2/tile/tile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ packages:
nats:
from: nats
deployment: (( ..cf.deployment_name ))
- name: health_check
- name: km_health_check
instances: [keymanager]
release: wso2am-release
colocated: true
Expand Down Expand Up @@ -284,7 +284,7 @@ packages:
nats:
from: nats
deployment: (( ..cf.deployment_name ))
- name: health_check
- name: apim_health_check
instances: [wso2apim]
release: wso2am-release
colocated: true
Expand Down Expand Up @@ -339,7 +339,7 @@ packages:
nats:
from: nats
deployment: (( ..cf.deployment_name ))
- name: health_check
- name: gw_health_check
instances: [gateway]
release: wso2am-release
colocated: true
Expand Down