Skip to content

[Bug] macOS LaunchAgent gateway does not respawn after SIGTERM; launchd reports 'domain in on-demand-only mode' #53475

Description

@dafacto

What version of OpenClaw are you using?

2026.3.13

What platform are you on?

macOS

What happened?

A gateway installed as a macOS LaunchAgent appears to shut down cleanly on SIGTERM, but does not automatically respawn afterward.

Instead, launchd leaves the service inactive and logs:

pending spawn, domain in on-demand-only mode: ai.openclaw.gateway

The gateway remains down until an explicit/manual restart or some later demand-triggered startup occurs.

This was initially mistaken for a state-bloat issue, but we reproduced it independently on a healthy instance with small state and no OOM behavior.

Expected behavior

If the installed gateway service receives SIGTERM, it should be restarted automatically by launchd (or otherwise remain available as an always-on gateway service).

Actual behavior

After SIGTERM:

  • gateway process exits cleanly
  • launchctl print gui/<uid>/ai.openclaw.gateway shows state = not running
  • health endpoint stops responding
  • no immediate respawn happens
  • service only returns after explicit restart, e.g. launchctl kickstart -k gui/<uid>/ai.openclaw.gateway

Reproduction

  1. Install the gateway service on macOS using the normal OpenClaw service install flow.
  2. Confirm the service is healthy.
  3. Send SIGTERM to the running gateway process.
  4. Poll:
    • curl http://127.0.0.1:18789/health
    • launchctl print gui/<uid>/ai.openclaw.gateway

Reproduction result

Observed sequence:

  • before test:
    • gateway healthy
    • launchd service running
  • after SIGTERM:
    • health endpoint stops responding
    • launchctl shows service inactive / not running
    • no automatic respawn occurs
  • after manual restart:
    • launchctl kickstart -k gui/<uid>/ai.openclaw.gateway
    • health endpoint returns healthy again

Relevant logs

Gateway log:

[gateway] signal SIGTERM received
[gateway] received SIGTERM; shutting down

launchd / unified log:

service inactive: ai.openclaw.gateway
pending spawn, domain in on-demand-only mode: ai.openclaw.gateway

Manual recovery later shows:

launching: non-ipc demand
Successfully spawned node[...] because non-ipc demand

Additional notes

  • This was reproduced on a healthy instance with small persisted state, so it does not appear to depend on OOM or large session files.
  • The LaunchAgent had RunAtLoad = true and KeepAlive = true.
  • This may be a macOS LaunchAgent/session-domain issue rather than a gateway crash issue, but from the user perspective the installed service is not behaving as an always-on service after a clean termination.

Question

Is this expected behavior for the current macOS LaunchAgent install model, or should the installed gateway service be resilient to SIGTERM without requiring manual/demand restart?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions