mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
chore: an enhanced version of convenient node health check script (#2624)
This commit is contained in:
parent
1b65a47685
commit
cc9403f970
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# optional argument to specgify the ip address
|
# optional argument to specgify the ip address
|
||||||
ip_address=$1
|
ip_address="localhost:8645"
|
||||||
plain_text_out=false
|
plain_text_out=false
|
||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
@ -29,8 +29,6 @@ set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
|
|||||||
# Check if an IP address is provided as an argument
|
# Check if an IP address is provided as an argument
|
||||||
if [[ -n "$1" ]]; then
|
if [[ -n "$1" ]]; then
|
||||||
ip_address="$1"
|
ip_address="$1"
|
||||||
else
|
|
||||||
ip_address="localhost:8645"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if curl is available
|
# check if curl is available
|
||||||
@ -40,16 +38,24 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -s GET http://${ip_address}/health)
|
response=$(curl --connect-timeout 6 -s GET http://${ip_address}/health)
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -e "$(date +'%H:%M:%S') - Node may not be running or not reachable at http://${ip_address}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "${response}" ]]; then
|
if [[ -z "${response}" ]]; then
|
||||||
echo -e "$(date +'%H:%M:%S')\tnode health status is: unknown\n"
|
echo -e "$(date +'%H:%M:%S') - node health status is: unknown\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v jq &> /dev/null || [[ "$plain_text_out" = true ]]; then
|
if ! command -v jq &> /dev/null || [[ "$plain_text_out" = true ]]; then
|
||||||
echo -e "$(date +'%H:%M:%S')\tnode health status is: ${response}\n"
|
echo -e "$(date +'%H:%M:%S') - node health status is: ${response}\n"
|
||||||
else
|
else
|
||||||
echo -e "$(date +'%H:%M:%S')\tnode health status is:\n"
|
echo -e "$(date +'%H:%M:%S') - node health status is:\n"
|
||||||
echo "${response}" | jq .
|
echo "${response}" | jq . 2>/dev/null
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -e "${response}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user