gateway-watchdog
БесплатноЗапускает вложенные скриптыНе проверенWindows background watchdog for the OpenClaw Gateway: 5s health checks, auto-restart on crash, hidden no-window operation, tray status icon, and a maintenance…
от yuestuday406 установок в других каталогахОб этом скилле
Gateway Watchdog
A Windows background watchdog for the OpenClaw Gateway. It health-checks the Gateway every 5 seconds, automatically restarts it when it goes down, and runs hidden in the background — no CMD window — with a system-tray status icon.
Its key feature is a maintenance lock: while a repair such as doctor --fix
is running, the watchdog suspends all health checks and restart attempts, so the
two never fight each other. Version-agnostic path resolution, HTTP-first health
probing, log rotation, and deadlock-safe lock expiry are all included.
When to Use
- Gateway keeps crashing / restarting in a loop
- Watchdog log spams
!! Gateway OFFLINEeven though the port is listening - A
doctor --fixrun keeps getting interrupted by the watchdog trying to restart - You want the Gateway + watchdog to run hidden (no CMD window)
- Installing or repairing the watchdog service on Windows
Architecture
| Piece | File | Role |
|---|---|---|
| Watchdog | scripts/watchdog.ps1 |
Main loop, health check, restart, tray icon |
| Maintenance wrapper | scripts/watchdog-maintenance.ps1 |
Run a repair while holding the lock |
| Hidden launcher | scripts/run_gateway_silent.vbs |
Start Gateway with no window |
| Gateway script | scripts/gateway.cmd |
Dynamic path resolution, no version pin |
| Installer | scripts/install_watchdog_admin.bat |
One-shot admin setup for scheduled tasks |
Single-instance guard (v1.1.0)
The watchdog holds a named mutex for its whole lifetime:
$MUTEX_NAME = "Global\OpenClawWatchdog_SingleInstance"
$script:mutex = New-Object System.Threading.Mutex($false, $MUTEX_NAME)
$gotIt = $script:mutex.WaitOne(0)
if (-not $gotIt) { exit 0 }
Why this exists. v1.0.0 was launched by a 5-minute repetition trigger while
its own while ($true) loop never exited. Eight copies stacked in 25 minutes,
each polling the same status file and drawing its own tray icon. Fix has two
halves and both are required:
- Trigger — a long-running loop gets a logon trigger only. Repetition is for scripts that exit on their own.
- Code — the mutex above, so an unexpected launch path is harmless.
Verify a second copy really dies:
Start-Process wscript.exe -ArgumentList 'run_watchdog_silent.vbs' -WindowStyle Hidden
Start-Sleep -Seconds 6
@(Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -match 'watchdog\.ps1' }).Count
# must be 1
How the Maintenance Lock Works
The lock file is ~/.openclaw/watchdog-maintenance.lock (JSON: owner, pid, createdAt).
- Any repair routine creates the lock before it starts.
- While a fresh lock exists, the watchdog pauses all health judgement and restart attempts, and switches the tray icon to "maintenance".
- A lock older than
LOCK_STALE_SEC(default 300s) is treated as abandoned and removed automatically (dead-lock protection). - The lock is re-checked immediately before any restart, so maintenance that begins mid-wait still wins.
- The lock is released in a
finallyblock, always.
Usage
Check status
Get-Content "$env:USERPROFILE\.openclaw\watchdog-status.json" -Raw
Get-Content "$env:USERPROFILE\.openclaw\watchdog.log" -Tail 20
The status file holds: state (starting/ok/down/restarting/maintenance), cycle,
failCount, updatedAt, uptimeMin.
Run a repair safely (coordinated with the watchdog)
powershell -NoProfile -File "$env:USERPROFILE\.openclaw\workspace\watchdog-maintenance.ps1" doctor --fix --non-interactive
The wrapper takes the lock, runs the command, releases the lock. Never run a repair bare while the watchdog is live — it will fight you.
Install / repair (needs Administrator)
Right-click -> Run as administrator:
install_watchdog_admin.bat
This switches the Gateway task to the hidden VBS launcher, updates the Watchdog task to run hidden PowerShell, restarts the Gateway silently, and verifies the port.
Tray States
- Shield — healthy
- Warning — restarting
- Info — maintenance in progress
- Error — offline
$SHOW_TRAY = $false in watchdog.ps1 disables the tray (headless mode). Without
an interactive session the tray is skipped automatically — the status file is
still written.
Tuning (watchdog.ps1 top block)
| Var | Default | Meaning |
|---|---|---|
$CHECK_INTERVAL |
5 | seconds between checks |
$GATEWAY_PORT |
18789 | Gateway port |
$RESTART_THRESHOLD |
2 | consecutive failures before restart |
$LOCK_STALE_SEC |
300 | abandoned-lock timeout |
$DOCTOR_TIMEOUT_SEC |
90 | max doctor --fix runtime |
$DOCTOR_COOLDOWN_MIN |
10 | min gap between doctor runs |
$SELF_REFRESH_HOURS |
24 | relaunch self before shell limits |
The Four Scheduled-Task Flaws (v3 fix)
A default schtasks install of this watchdog can die silently. Four compounding causes:
| # | Flaw | Symptom | v3 fix |
|---|
Установить gateway-watchdog в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл gateway-watchdog?
Windows background watchdog for the OpenClaw Gateway: 5s health checks, auto-restart on crash, hidden no-window operation, tray status icon, and a maintenance lock that keeps repairs (doctor --fix) from racing the watchdog. Auto-repair is OFF by default; the watchdog only restarts the Gateway.
Как установить скилл gateway-watchdog?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gateway-watchdog запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic