Skip to content

Bug: openclaw gateway restart and openclaw status do not detect system-level systemd service  #87577

@fisherman86-ai

Description

@fisherman86-ai

Bug: openclaw gateway restart and openclaw status do not detect system-level systemd service

Summary

When OpenClaw Gateway is installed as a system-level systemd service (/etc/systemd/system/openclaw.service), the CLI fails to detect it:

  1. openclaw status reports Gateway service: systemd user not installedincorrect, the service is running via system-level systemd.
  2. openclaw gateway restart treats the process as an "unmanaged process" and only sends SIGTERM, rather than invoking systemctl restart openclaw.

Environment

  • OpenClaw version: 2026.5.26 (10ad3aa)
  • OS: Ubuntu 24.04, Linux 6.8.0-63-generic (x64)
  • Node: v24.15.0
  • Installation: global via pnpm (/usr/lib/node_modules/openclaw)
  • Service type: system-level systemd (/etc/systemd/system/openclaw.service)

Reproduction

1. Install as system-level service

# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw Gateway
After=network.target

[Service]
Type=simple
User=admin
Group=admin
WorkingDirectory=/home/admin
Environment="HOME=/home/admin"
Environment="PATH=/home/admin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/usr/bin/node /usr/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

2. Start the service

sudo systemctl enable --now openclaw

3. Check status — incorrect detection

$ openclaw status
# Shows: "Gateway service: systemd user not installed"
# Actual: running under /system.slice/openclaw.service

4. Try restart — doesn't work as expected

$ openclaw gateway restart
# Output: "Gateway restart signal sent to unmanaged process on port 18789: <PID>."
# What happens: SIGTERM sent → process killed → systemd Restart=always brings it back
# Expected: `systemctl restart openclaw` should be called instead

$ sudo systemctl restart openclaw
# This works correctly

Evidence that the process IS systemd-managed

$ cat /proc/<PID>/cgroup
0::/system.slice/openclaw.service

$ cat /proc/<PID>/environ | tr '\0' '\n' | grep -E "INVOCATION_ID|JOURNAL_STREAM|SYSTEMD_EXEC_PID"
INVOCATION_ID=22297bc9c5ea47198333b515911c6cf3
JOURNAL_STREAM=8:39385614
SYSTEMD_EXEC_PID=<PID>

Root Cause

The CLI only checks for a user-level systemd service (~/.config/systemd/user/openclaw.service) and does not check for a system-level service (/etc/systemd/system/openclaw.service).

Expected Behavior

  1. openclaw status should detect system-level systemd services and report the service status correctly.
  2. openclaw gateway restart should invoke systemctl restart openclaw (with appropriate privileges or a helpful error message) when the gateway is managed by a system-level systemd service.

Workaround

Use sudo systemctl restart openclaw directly instead of openclaw gateway restart.

Suggested Fix

In the service detection logic, also check for system-level systemd services:

1. Check ~/.config/systemd/user/openclaw.service  (user-level)
2. Check /etc/systemd/system/openclaw.service     (system-level)  ← currently missing
3. Check for INVOCATION_ID / SYSTEMD_EXEC_PID in process environment as a fallback signal

When a system-level service is detected, openclaw gateway restart should either:

  • Call systemctl restart openclaw (requires sudo/polkit), or
  • Print a clear message: "Gateway is managed by system-level systemd. Use: sudo systemctl restart openclaw"

The current behavior of silently SIGTERM-ing the process and relying on Restart=always to recover is fragile and confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    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