一键导入
hermes-watchdog
Set up a watchdog for hermes gateway — heartbeat detection and auto-restart when the process hangs or becomes unresponsive.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up a watchdog for hermes gateway — heartbeat detection and auto-restart when the process hangs or becomes unresponsive.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Consolidate scattered utility scripts into a centralized directory with comprehensive documentation, then publish to version control.
Debug cron job execution failures — check job status, session logs, gateway errors, model availability, and stale gateway code
Hermes gateway port 8642 is WebSocket-based only — NOT a REST API. Do NOT try to send WeChat/Weixin alerts via curl HTTP POST to the gateway. Understanding this prevents wasted time debugging "404 on all endpoints" when trying to send alerts from cron jobs.
Karpathy's LLM Wiki — build and maintain a persistent, interlinked markdown knowledge base. Ingest sources, query compiled knowledge, and lint for consistency.
A股每日/每周收盘行情汇总报告生成 — 东方财富 API 为主,AKShare (Sina + 同花顺) 兜底
每日美股收盘行情汇总 — 主要指数、板块轮动、个股亮点、宏观消息面、技术分析
| name | hermes-watchdog |
| description | Set up a watchdog for hermes gateway — heartbeat detection and auto-restart when the process hangs or becomes unresponsive. |
| version | 1.0.0 |
| author | Hermes Agent |
| license | MIT |
| metadata | {"hermes":{"tags":["hermes","watchdog","heartbeat","auto-restart","launchd","macos"]}} |
Launchd only restarts hermes on process exit — it won't detect a hung or unresponsive gateway. This watchdog adds heartbeat detection via the /health endpoint.
http://127.0.0.1:8642/health every 2 minutescat > ~/.hermes/scripts/hermes-watchdog.sh << 'SCRIPT'
#!/bin/bash
HEALTH_URL="http://127.0.0.1:8642/health"
LOG="$HOME/.hermes/logs/watchdog.log"
FAIL_COUNT=0
MAX_FAIL=3
CHECK_INTERVAL=120
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$LOG"
}
restart_gateway() {
log "WARN: 连续 $MAX_FAIL 次健康检查失败,正在重启 hermes gateway..."
launchctl unload ~/Library/LaunchAgents/ai.hermes.gateway.plist 2>>"$LOG"
sleep 3
launchctl load ~/Library/LaunchAgents/ai.hermes.gateway.plist 2>>"$LOG"
sleep 10
if curl -sf --max-time 5 "$HEALTH_URL" > /dev/null 2>&1; then
log "OK: gateway 重启成功"
else
log "ERROR: gateway 重启后仍无响应!"
fi
FAIL_COUNT=0
}
log "INFO: watchdog 启动,检查间隔 ${CHECK_INTERVAL}s,容错次数 $MAX_FAIL"
while true; do
if curl -sf --max-time 5 "$HEALTH_URL" > /dev/null 2>&1; then
FAIL_COUNT=0
else
FAIL_COUNT=$((FAIL_COUNT + 1))
log "WARN: 健康检查失败 ($FAIL_COUNT/$MAX_FAIL)"
if [ $FAIL_COUNT -ge $MAX_FAIL ]; then
restart_gateway
FAIL_COUNT=0
fi
fi
sleep $CHECK_INTERVAL
done
SCRIPT
chmod +x ~/.hermes/scripts/hermes-watchdog.sh
cat > ~/Library/LaunchAgents/ai.hermes.watchdog.plist << 'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ai.hermes.watchdog</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/huidge/.hermes/scripts/hermes-watchdog.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/huidge/.hermes/logs/watchdog.stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/huidge/.hermes/logs/watchdog.stderr.log</string>
</dict>
</plist>
PLIST
launchctl load ~/Library/LaunchAgents/ai.hermes.watchdog.plist
# Check watchdog process is running
ps aux | grep hermes-watchdog | grep -v grep
# Check watchdog logs
tail -f ~/.hermes/logs/watchdog.log
~/.hermes/config.yaml for port: — default is 8642 but may differKeepAlive: true (not just on failure) since it's a long-running loop script