openclaw - 💡(How to fix) Fix [Feature] Windows: crash auto-restart parity with systemd Restart=always / launchd KeepAlive [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

# Trigger
$trigger = New-ScheduledTaskTrigger -Once `
    -At (Get-Date).AddMinutes(1) `
    -RepetitionInterval (New-TimeSpan -Minutes 3) `
    -RepetitionDuration (New-TimeSpan -Days 9999)

# Check script (watchdog-check.ps1)
$port = 18789
$conn = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if (-not $conn) {
    Add-Content -Path "$env:USERPROFILE\.openclaw\logs\watchdog.log" -Value "$(Get-Date) Gateway not running, starting..."
    Start-Process -FilePath "C:\Users\<user>\.openclaw\gateway.cmd" -WindowStyle Minimized
}
RAW_BUFFERClick to expand / collapse

Problem

openclaw gateway install on Linux creates a systemd unit with Restart=always, and on macOS creates a LaunchAgent with KeepAlive=true. Both provide automatic crash recovery.

On Windows, the scheduled task created by the same command uses only ONLOGON trigger — it starts the gateway at login but provides no crash auto-restart. If the gateway dies mid-session, it stays dead.

This is a platform parity gap: Windows users are unprotected against gateway crashes.

Current state

In current main (src/daemon/schtasks.ts), the Windows install path creates a ONLOGON trigger with no repetition interval or duration. As noted by @clawsweeper in https://github.com/openclaw/openclaw/issues/81020, the update path only runs /Change /TN ... /TR ... and does not repair missing repetition on existing tasks.

Proposed solution

Add a dedicated watchdog scheduled task (OpenClaw Watchdog) during gateway install that:

  • Checks port 18789 on a repeat interval (e.g. 3 minutes)
  • If the port is not listening, starts gateway.cmd
  • Uses wscript.exe as launcher (no console flash on trigger)
  • Uses IgnoreNew multiple-instance policy (skip when already running)
  • Uses P9999D repetition duration (effectively indefinite)

Proven design

We've been running this exact design in production since 2026-05-12 without issues:

# Trigger
$trigger = New-ScheduledTaskTrigger -Once `
    -At (Get-Date).AddMinutes(1) `
    -RepetitionInterval (New-TimeSpan -Minutes 3) `
    -RepetitionDuration (New-TimeSpan -Days 9999)

# Check script (watchdog-check.ps1)
$port = 18789
$conn = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if (-not $conn) {
    Add-Content -Path "$env:USERPROFILE\.openclaw\logs\watchdog.log" -Value "$(Get-Date) Gateway not running, starting..."
    Start-Process -FilePath "C:\Users\<user>\.openclaw\gateway.cmd" -WindowStyle Minimized
}

Related: https://github.com/openclaw/openclaw/issues/81020 (the P1D duration expiry variant of the same gap).

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING