fix status check scirpt

This commit is contained in:
Simon Larsen 2023-09-29 14:16:09 +01:00
parent 53efbaf7a0
commit 36860e6ee9
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 58 additions and 44 deletions

View File

@ -0,0 +1,39 @@
#!/bin/bash
# Set the endpoint URL
endpoint_url=$2
name=$1
# if name or endpoint is not provided, exit
if [ $# -eq 0 ]; then
echo "❌ Error: Please provide a name and endpoint URL"
exit 1
fi
# Set the maximum number of retries
max_retries=20 # This allows for 12 attempts, which totals 1 minute with 5 seconds between each retry
retry_interval=5 # Retry interval in seconds
# Initialize variables
retries=0
http_status=0
# Loop until either the endpoint returns 200 or the maximum retries are reached
while [ $retries -lt $max_retries ]; do
# Make a curl request and capture the HTTP status code
http_status=$(curl -s -o /dev/null -w "%{http_code}" $endpoint_url)
# Check if the HTTP status code is 200 (OK)
if [ $http_status -eq 200 ]; then
echo "$name endpoint is up "
exit 0 # Exit the script with success status
else
echo "$name $endpoint_url returned HTTP $http_status, retrying in $retry_interval seconds..."
sleep $retry_interval
retries=$((retries + 1))
fi
done
# If the loop exits without getting HTTP 200, throw an error
echo "❌ Error: Maximum retries reached, $name still not returning HTTP 200. It could be down or taking longer than expected to start."
exit 1 # Exit the script with an error status

View File

@ -1,70 +1,45 @@
#!/bin/bash
scriptDir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")")
HOST_TO_CHECK="$1"
if [ $# -eq 0 ]; then
HOST_TO_CHECK="localhost"
fi
echo "Basic check in progress..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/)" != "200" ]]; do sleep 5; done"
echo "Basic checks complete ✔️"
echo "Checking Home Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/status)" != "200" ]]; do sleep 5; done"
echo "Home Server is up ✔️"
echo "We will need to wait ~5-10 minutes for things to settle down, migrations to finish, and TLS certs to be issued"
echo ""
echo "⏳ Waiting for OneUptime to boot (this will take a few minutes)"
echo "Checking API Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/api/status)" != "200" ]]; do sleep 5; done"
echo "API is up ✔️"
bash $scriptDir/endpoint-status.sh "Basic Check" $HOST_TO_CHECK/
echo "Checking Dashboard Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/dashboard/status)" != "200" ]]; do sleep 5; done"
echo "Dashboard is up ✔️"
bash $scriptDir/endpoint-status.sh "Home" $HOST_TO_CHECK/status
echo "Checking File Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/file/status)" != "200" ]]; do sleep 5; done"
echo "File server is up ✔️"
bash $scriptDir/endpoint-status.sh "API" $HOST_TO_CHECK/api/status
echo "Checking Status Page Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/status-page/status)" != "200" ]]; do sleep 5; done"
echo "Status Page Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Dashboard" $HOST_TO_CHECK/dashboard/status
echo "Checking Accounts Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/accounts/status)" != "200" ]]; do sleep 5; done"
echo "Accounts Server is up ✔️"
bash $scriptDir/endpoint-status.sh "File" $HOST_TO_CHECK/file/status
echo "Checking Notification Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/notification/status)" != "200" ]]; do sleep 5; done"
echo "Notification Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Status Page" $HOST_TO_CHECK/status-page/status
echo "Checking Worker Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/workers/status)" != "200" ]]; do sleep 5; done"
echo "Worker Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Accounts" $HOST_TO_CHECK/accounts/status
echo "Checking Identity Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/identity/status)" != "200" ]]; do sleep 5; done"
echo "Identity Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Notification" $HOST_TO_CHECK/notification/status
echo "Checking Workflow Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/workflow/status)" != "200" ]]; do sleep 5; done"
echo "Workflow Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Worker" $HOST_TO_CHECK/workers/status
echo "Checking API Docs Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/reference/status)" != "200" ]]; do sleep 5; done"
echo "API Docs Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Identity" $HOST_TO_CHECK/identity/status
echo "Checking Link Shortener Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/l/status)" != "200" ]]; do sleep 5; done"
echo "Link Shortener Server is up ✔️"
bash $scriptDir/endpoint-status.sh "Workflow" $HOST_TO_CHECK/workflow/status
bash $scriptDir/endpoint-status.sh "API Docs" $HOST_TO_CHECK/reference/status
bash $scriptDir/endpoint-status.sh "Link Shortener" $HOST_TO_CHECK/l/status
bash $scriptDir/endpoint-status.sh "Admin Dashboard" $HOST_TO_CHECK/admin/status
echo "Checking Admin Dashboard Server Status..."
bash -c "while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HOST_TO_CHECK/admin/status)" != "200" ]]; do sleep 5; done"
echo "Admin Dashboard Server is up ✔️"
echo "⌛️ OneUptime is up!"
echo ""