openclaw - ✅(Solved) Fix [Bug]: gateway restart misdetects system-level systemd service [1 pull requests, 5 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#44575Fetched 2026-04-08 00:45:01
View on GitHub
Comments
5
Participants
2
Timeline
11
Reactions
1
Timeline (top)
commented ×5cross-referenced ×2subscribed ×2mentioned ×1

openclaw gateway restart appears to assume a user-level systemd service (systemctl --user) and does not properly support gateways installed as a system-level systemd service.

In practice, some operators deploy OpenClaw as a system service (for example on servers, appliances, or root-managed hosts). In that setup, the restart path should detect whether the gateway is managed by:

  • user systemd → systemctl --user restart openclaw-gateway.service
  • system/root systemd → systemctl restart openclaw-gateway.service

Right now, the CLI behavior does not appear to account for that distinction, so openclaw gateway restart can become ineffective or misleading when the gateway is installed as a system service.

Root Cause

OpenClaw is not always deployed under a normal user session. Some users intentionally run it as a root/system-managed service for:

  • headless servers / VPS
  • system boot lifecycle management
  • central service supervision
  • environments where user session DBus or --user units are undesirable

In those cases, a restart command that always follows the user-service path is incomplete.

Fix Action

Fixed

PR fix notes

PR #44628: fix(infra): detect systemd service scope before restart

Description (problem / solution / changelog)

Fixes #44575 - Gateway restart misdetects system-level systemd service

Root Cause

The triggerOpenClawRestart() function in src/infra/restart.ts always tried the user service (systemctl --user) first, then fell back to the system service. This approach:

  • Was inefficient for system service deployments
  • Did not report which service type was actually used
  • Could be confusing for operators using system-level services

Fix

Added service scope detection logic that:

  1. Detects enabled services: Uses systemctl is-enabled to check if user or system service is enabled
  2. Detects active services: Uses systemctl is-active to check which service is running
  3. Prefers the correct scope: Selects the service scope based on detection priority:
    • Services that are both enabled AND active (highest priority)
    • Services that are enabled only
    • Services that are active only
  4. Reports detection result: Includes the detected service type in the return detail field
  5. Provides fallback: If the preferred scope fails, tries the other scope

Detection Priority

user (enabled+active) > system (enabled+active) >
user (enabled) > system (enabled) >
user (active) > system (active)

Test Plan

  • Test on system with user service only → should use user service
  • Test on system with system service only → should use system service
  • Test on system with both services → should prefer the active/enabled one
  • Test on system with neither service → should try both (original behavior)

Example Output

  • User service detected: systemctl --user restart openclaw-gateway.service [user (enabled+active)]
  • System service detected: systemctl restart openclaw-gateway.service [system (enabled+active)]
  • Fallback: systemctl restart openclaw-gateway.service [user (enabled)]; fallback to system

Changed files

  • docker-setup.sh (modified, +1/-3)
  • src/infra/restart.ts (modified, +130/-3)
RAW_BUFFERClick to expand / collapse

Bug type

Feature gap / Linux systemd compatibility

Summary

openclaw gateway restart appears to assume a user-level systemd service (systemctl --user) and does not properly support gateways installed as a system-level systemd service.

In practice, some operators deploy OpenClaw as a system service (for example on servers, appliances, or root-managed hosts). In that setup, the restart path should detect whether the gateway is managed by:

  • user systemd → systemctl --user restart openclaw-gateway.service
  • system/root systemd → systemctl restart openclaw-gateway.service

Right now, the CLI behavior does not appear to account for that distinction, so openclaw gateway restart can become ineffective or misleading when the gateway is installed as a system service.

Why this matters

OpenClaw is not always deployed under a normal user session. Some users intentionally run it as a root/system-managed service for:

  • headless servers / VPS
  • system boot lifecycle management
  • central service supervision
  • environments where user session DBus or --user units are undesirable

In those cases, a restart command that always follows the user-service path is incomplete.

Expected behavior

openclaw gateway restart should:

  1. Detect how the gateway is installed/managed
  2. If it is a user service, use the user-service restart path
  3. If it is a system service, use the system-service restart path
  4. Report clearly which service manager/scope was detected

Example desired behavior:

  • Detected: systemd user service → restart with systemctl --user restart ...
  • Detected: systemd system service → restart with systemctl restart ...
  • If both exist, explain which one is active and why that one was chosen

Actual behavior

The current restart flow appears biased toward the --user service model, which means system-level deployments are not properly handled.

This creates confusion such as:

  • restart command does nothing useful for system service installs
  • service state detection is misleading
  • root/system-managed deployments need manual service commands even though the CLI exposes openclaw gateway restart

Suggested fix

  • Add explicit detection for systemd user vs system service installation
  • Route restart/start/stop/status behavior to the correct command path
  • Surface the detected scope in CLI output
  • Consider documenting supported deployment modes and their restart semantics

OpenClaw version

Current recent releases (observed in real deployments)

Operating system

Linux / systemd

Install method

npm global / manual service deployment

Logs, screenshots, and evidence

Reproduction is straightforward conceptually:

  1. Install and run OpenClaw gateway as a system-level systemd service
  2. Run openclaw gateway restart
  3. Observe that the CLI path does not correctly account for system-service management
  4. Manually run systemctl restart openclaw-gateway.service
  5. Observe that the system service restart path is the relevant one

Impact and severity

Medium

This does not block all deployments, but it makes an official CLI lifecycle command unreliable/incomplete for a legitimate Linux deployment mode.

Additional information

There is already a related issue for user-level systemd restart problems:

  • #40275

This issue is specifically about supporting system/root-level systemd gateway deployments instead of assuming the gateway always lives under systemctl --user.

extent analysis

Fix Plan

To address the issue, we need to modify the openclaw gateway restart command to detect whether the gateway is installed as a user-level or system-level systemd service. Here are the steps:

  • Check if the gateway is installed as a system-level service:
    • Run systemctl list-units --type=service --state=running and check if openclaw-gateway.service is in the output.
  • Check if the gateway is installed as a user-level service:
    • Run systemctl --user list-units --type=service --state=running and check if openclaw-gateway.service is in the output.
  • Based on the detection, use the corresponding restart command:
    • If system-level service is detected, use systemctl restart openclaw-gateway.service.
    • If user-level service is detected, use systemctl --user restart openclaw-gateway.service.
  • Surface the detected scope in CLI output.

Example code snippet in JavaScript:

const childProcess = require('child_process');

// Detect system-level service
const systemService = childProcess.execSync('systemctl list-units --type=service --state=running').toString().includes('openclaw-gateway.service');

// Detect user-level service
const userService = childProcess.execSync('systemctl --user list-units --type=service --state=running').toString().includes('openclaw-gateway.service');

if (systemService) {
  console.log('Detected system-level service. Restarting...');
  childProcess.execSync('systemctl restart openclaw-gateway.service');
} else if (userService) {
  console.log('Detected user-level service. Restarting...');
  childProcess.execSync('systemctl --user restart openclaw-gateway.service');
} else {
  console.log('No service detected.');
}

Verification

To verify the fix, follow these steps:

  • Install OpenClaw gateway as a system-level systemd service.
  • Run openclaw gateway restart and check if the service is restarted correctly.
  • Install OpenClaw gateway as a user-level systemd service.
  • Run openclaw gateway restart and check if the service is restarted correctly.

Extra Tips

  • Make sure to handle errors and exceptions properly when executing the systemctl commands.
  • Consider adding a flag or option to the openclaw gateway restart command to force the use of a specific service type (e.g. --system or --user).

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…

FAQ

Expected behavior

openclaw gateway restart should:

  1. Detect how the gateway is installed/managed
  2. If it is a user service, use the user-service restart path
  3. If it is a system service, use the system-service restart path
  4. Report clearly which service manager/scope was detected

Example desired behavior:

  • Detected: systemd user service → restart with systemctl --user restart ...
  • Detected: systemd system service → restart with systemctl restart ...
  • If both exist, explain which one is active and why that one was chosen

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: gateway restart misdetects system-level systemd service [1 pull requests, 5 comments, 2 participants]