Skip to content

[Bug]: [Windows] Gateway service lacks auto-restart mechanism and file logging (unlike macOS) #11081

@fhfhjad

Description

@fhfhjad

Description

On Windows, the OpenClaw gateway service has two critical deficiencies compared to macOS:

  1. No auto-restart mechanism after crash (macOS has launchd KeepAlive)
  2. No file logging - errors are lost when running via scheduled task

These issues make Windows deployments unreliable and difficult to debug.


Problem 1: No Auto-Restart After Crash

macOS behavior (working)

  • Uses launchd with KeepAlive: true
  • When gateway process crashes, launchd automatically restarts it
  • Feishu and other connections are automatically re-established

Windows behavior (broken)

  • Uses schtasks (Scheduled Task) without any keep-alive mechanism
  • When gateway process crashes, the service remains stopped
  • No automatic restart occurs
  • User must manually run openclaw gateway start to recover service
  • Feishu bot remains unresponsive until manual intervention

Root Cause

From src/daemon/schtasks.ts, the Windows scheduled task is created with:

const baseArgs = [
  "/Create",
  "/F",
  "/SC", "ONLOGON",  // Only runs once at user login
  "/RL", "LIMITED",
  "/TN", taskName,
  "/TR", quoteCmdArg(scriptPath)  // Points to gateway.cmd
];

There is no configuration for automatic restart on failure.

In contrast, macOS src/daemon/launchd.ts generates:

<key>KeepAlive</key>
<true/>

Problem 2: No File Logging

macOS behavior (working)

The launchd plist configuration includes:

<key>StandardOutPath</key>
<string>/path/to/gateway.log</string>
<key>StandardErrorPath</key>
<string>/path/to/gateway.err.log</string>

All stdout and stderr output is persisted to log files for debugging.

Windows behavior (broken)

The generated gateway.cmd contains:

@echo off
rem OpenClaw Gateway (v2026.2.3-1)
set PATH=...
set OPENCLAW_GATEWAY_PORT=18789
...
"D:\Program Files\nodejs\node.exe" C:\...\openclaw\dist\index.js gateway --port 18789

There is no output redirection. When the scheduled task runs this script:

  • Console output is discarded
  • Error messages are lost
  • Crash reasons cannot be determined
  • No ~/.openclaw/logs/ directory is created

Impact

These deficiencies cause significant issues for Windows users:

Issue Impact
No auto-restart Gateway crashes → service down indefinitely → Feishu bot unresponsive
No file logging Cannot diagnose why gateway crashed → impossible to troubleshoot
Manual recovery required User must notice outage and manually restart service

Windows users experience much lower reliability compared to macOS users due to these missing features.


Environment

  • OS: Windows 10/11
  • OpenClaw Version: 2026.2.3-1
  • Node.js Version: v24.13.0
  • Installation Method: npm global install

Related Code

  • src/daemon/schtasks.ts - Windows service installation (lacks KeepAlive equivalent)
  • src/daemon/launchd.ts - macOS service installation (has KeepAlive and logging)
  • src/daemon/service.ts - Platform abstraction layer

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions