AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning
This commit is contained in:
44
scripts/notify-gateway-restart.sh
Executable file
44
scripts/notify-gateway-restart.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Polls the OpenClaw gateway health endpoint.
|
||||
# Sends a Telegram notification whenever it recovers after being unreachable.
|
||||
|
||||
BOT_TOKEN="8598508497:AAHmTMbnR7un2ADtmsjJr8moQkDOU9ILBps"
|
||||
CHAT_ID="1793951355"
|
||||
GATEWAY_URL="http://127.0.0.1:18789"
|
||||
POLL_INTERVAL=3 # seconds between checks
|
||||
LOG_PREFIX="[$(date '+%Y-%m-%d %H:%M:%S')]"
|
||||
|
||||
send_notification() {
|
||||
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"chat_id\": \"${CHAT_ID}\",
|
||||
\"text\": \"✅ *Krilly is back online!*\n\nOpenClaw gateway restarted and is ready to go 🦀\",
|
||||
\"parse_mode\": \"Markdown\"
|
||||
}" > /dev/null
|
||||
}
|
||||
|
||||
is_up() {
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 3 "${GATEWAY_URL}/health" 2>/dev/null)
|
||||
[ "$STATUS" = "200" ] || [ "$STATUS" = "401" ]
|
||||
}
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') Gateway watcher started"
|
||||
|
||||
WAS_UP=true
|
||||
|
||||
while true; do
|
||||
if is_up; then
|
||||
if [ "$WAS_UP" = "false" ]; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') Gateway recovered — sending notification"
|
||||
send_notification
|
||||
fi
|
||||
WAS_UP=true
|
||||
else
|
||||
if [ "$WAS_UP" = "true" ]; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') Gateway went down"
|
||||
fi
|
||||
WAS_UP=false
|
||||
fi
|
||||
sleep "$POLL_INTERVAL"
|
||||
done
|
||||
Reference in New Issue
Block a user