Last active
September 6, 2024 06:32
-
-
Save odolbeau/bd6d8eb7910d1289e2687682c8db9275 to your computer and use it in GitHub Desktop.
Healtchecks.io bash decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Hosted on gist : https://gist.github.com/odolbeau/bd6d8eb7910d1289e2687682c8db9275 | |
if [ $# -lt 1 ] || [ -z "$1" ] || [ -z "${UUID}" ]; then | |
echo "Usage: UUID=your-uuid $0 [command to run]" | |
echo "Decorates a command to notify healtchecks.io" | |
exit 1 | |
fi | |
curl -fsS -m 10 --retry 5 -o /dev/null "https://hc-ping.com/$UUID/start" | |
LOG_FILE=/tmp/healtchecks.io-$(echo $RANDOM | md5sum | head -c 20).log | |
"$@" > "$LOG_FILE" 2>&1 | |
RETURN_CODE=$? | |
OUTPUT=$(tail --bytes=100000 "$LOG_FILE") | |
rm "$LOG_FILE" | |
curl -fsS -m 10 --retry 5 --data-raw "$OUTPUT" -o /dev/null "https://hc-ping.com/$UUID/$RETURN_CODE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment