openclaw - 💡(How to fix) Fix Bug: `openclaw gateway restart` and `openclaw status` do not detect system-level systemd service

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…

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.

Error Message

  1. 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.

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).

Fix Action

Workaround

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

Code Example

# /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

---

sudo systemctl enable --now openclaw

---

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

---

$ 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

---

$ 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>

---

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
RAW_BUFFERClick to expand / collapse

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.

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