openclaw - ✅(Solved) Fix [Bug]: openclaw gateway restart fails to restart service (SIGTERM instead of SIGUSR1) [5 pull requests, 1 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#44490Fetched 2026-04-08 00:46:11
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×4referenced ×4labeled ×2commented ×1

Description When running openclaw gateway restart, the Gateway service stops but fails to restart. Only a manual system restart (or computer reboot) restores the service.

Root Cause

Description When running openclaw gateway restart, the Gateway service stops but fails to restart. Only a manual system restart (or computer reboot) restores the service.

Fix Action

Fixed

PR fix notes

PR #44494: fix(daemon): trigger SIGUSR1 in-process restart when scheduling launchd handoff

Description (problem / solution / changelog)

Summary

Fixes #44490 - Gateway restart fails with SIGTERM instead of SIGUSR1.

Root Cause

When openclaw gateway restart was called from within the LaunchAgent-managed gateway process, the code would schedule a detached handoff script but never send SIGUSR1 to trigger graceful in-process restart. The process would eventually receive SIGTERM from launchd's kickstart -k and terminate completely instead of restarting gracefully.

In restartLaunchAgent() (src/daemon/launchd.ts), when isCurrentProcessLaunchdServiceLabel() returns true:

  • Before: Only scheduled handoff script, process never got SIGUSR1
  • After: Send SIGUSR1 first to trigger in-process restart, then schedule handoff as fallback

Fix

Modified restartLaunchAgent() to send SIGUSR1 signal before scheduling the handoff:

  1. First triggers in-process restart via SIGUSR1 (graceful shutdown + reinitialization)
  2. Then schedules detached handoff script as fallback (ensures new instance starts if process exits)
  3. Includes error handling: if SIGUSR1 fails, logs warning but continues with handoff

This ensures the gateway logs show [gateway] signal SIGUSR1 received instead of terminating with SIGTERM.

Test plan

  • Type check passes (no new errors in src/daemon/launchd.ts)
  • All 23 tests in src/daemon/launchd.test.ts pass
  • All lifecycle and restart tests pass:
    • src/daemon/launchd-restart-handoff.test.ts (1 test)
    • src/cli/daemon-cli/lifecycle.test.ts (8 tests)
    • src/cli/gateway-cli/run-loop.test.ts (8 tests)

Manual verification

To test on macOS with LaunchAgent:

  1. Start gateway: openclaw gateway run --bind loopback
  2. From another terminal: openclaw gateway restart
  3. Expected: Gateway logs show signal SIGUSR1 received and restarts gracefully
  4. Before fix: Gateway would terminate with signal SIGTERM received and not restart

Changed files

  • src/daemon/launchd.ts (modified, +18/-0)

PR #44495: fix: add missing 'xhigh' option to --thinking help text

Description (problem / solution / changelog)

描述

修复 #44443: CLI --thinking help text missing 'xhigh' option

变更内容

  • 更新 src/cli/cron-cli/register.cron-add.ts 中的help text,添加xhigh选项
  • 更新 src/cli/cron-cli/register.cron-edit.ts 中的help text,添加xhigh选项

测试

  • 本地测试通过
  • pnpm build 通过
  • 代码变更符合项目规范

AI辅助声明

  • 此PR使用AI辅助生成
  • 已进行充分测试
  • 理解代码变更内容

Changed files

  • .agent-team/agents/code-reviewer.md (added, +64/-0)
  • .agent-team/agents/issue-finder.md (added, +47/-0)
  • .agent-team/agents/issue-fixer.md (added, +49/-0)
  • .agent-team/agents/pr-submitter.md (added, +83/-0)
  • .agent-team/coordinator.ts (added, +670/-0)
  • .agent-team/logs/coordinator.log (added, +13/-0)
  • .agent-team/state/issue-44490-analysis.md (added, +1716/-0)
  • .agent-team/state/progress.json (added, +13/-0)
  • src/cli/cron-cli/register.cron-add.ts (modified, +1/-1)
  • src/cli/cron-cli/register.cron-edit.ts (modified, +1/-1)

PR #44514: fix(daemon): trigger SIGUSR1 in-process restart when scheduling launchd handoff

Description (problem / solution / changelog)

Summary

Fixes #44490 - Gateway restart fails with SIGTERM instead of SIGUSR1.

Root Cause

When openclaw gateway restart was called from within the LaunchAgent-managed gateway process, the code would schedule a detached handoff script but never send SIGUSR1 to trigger graceful in-process restart. The process would eventually receive SIGTERM from launchd's kickstart -k and terminate completely instead of restarting gracefully.

In restartLaunchAgent() (src/daemon/launchd.ts), when isCurrentProcessLaunchdServiceLabel() returns true:

  • Before: Only scheduled handoff script, process never got SIGUSR1
  • After: Send SIGUSR1 first to trigger in-process restart, then schedule handoff as fallback

Fix

Modified restartLaunchAgent() to send SIGUSR1 signal before scheduling the handoff:

  1. First triggers in-process restart via SIGUSR1 (graceful shutdown + reinitialization)
  2. Then schedules detached handoff script as fallback (ensures new instance starts if process exits)
  3. Includes error handling: if SIGUSR1 fails, logs warning but continues with handoff

This ensures the gateway logs show [gateway] signal SIGUSR1 received instead of terminating with SIGTERM.

Test plan

  • Type check passes (no new errors in src/daemon/launchd.ts)
  • All 23 tests in src/daemon/launchd.test.ts pass
  • All lifecycle and restart tests pass:
    • src/daemon/launchd-restart-handoff.test.ts (1 test)
    • src/cli/daemon-cli/lifecycle.test.ts (8 tests)
    • src/cli/gateway-cli/run-loop.test.ts (8 tests)

Manual verification

To test on macOS with LaunchAgent:

  1. Start gateway: openclaw gateway run --bind loopback
  2. From another terminal: openclaw gateway restart
  3. Expected: Gateway logs show signal SIGUSR1 received and restarts gracefully
  4. Before fix: Gateway would terminate with signal SIGTERM received and not restart

Changed files

  • src/daemon/launchd.ts (modified, +18/-0)

PR #44518: fix(daemon): trigger SIGUSR1 in-process restart when scheduling launchd handoff

Description (problem / solution / changelog)

Fixes #44490 - Gateway restart fails to restart service (SIGTERM instead of SIGUSR1)

Root Cause

When restarting from within the gateway process (detected via isCurrentProcessLaunchdServiceLabel()), the code only scheduled a detached handoff script but never triggered the in-process graceful restart via SIGUSR1. This meant the gateway would receive SIGTERM from launchd instead of gracefully restarting.

Fix

Emit SIGUSR1 before scheduling the handoff script. This ensures:

  1. The gateway gracefully restarts in-process (via SIGUSR1 handler)
  2. The handoff script waits for the process to exit
  3. A new instance starts after the current process terminates

Follows the same pattern used by emitGatewayRestart() in src/infra/restart.ts.

Test plan

  • All launchd-related tests pass (launchd.test.ts 23 tests)
  • Gateway restart from within process triggers SIGUSR1
  • Handoff script still starts new instance after process exits

Changed files

  • src/daemon/launchd.ts (modified, +18/-0)

PR #44531: fix: gateway restart sends SIGUSR1 via systemctl reload instead of SIGTERM (#44490)

Description (problem / solution / changelog)

Problem

Running openclaw gateway restart when the gateway is managed by systemd stops the service but fails to restart it properly. The gateway log shows it received SIGTERM instead of SIGUSR1.

Root Cause

When the systemd service is loaded, runServiceRestart() in lifecycle-core.ts calls service.restart(), which maps to restartSystemdService() in systemd.ts. This function ran systemctl --user restart <unit>, which sends SIGTERM to stop the process, then starts a new one.

However, the gateway run-loop (run-loop.ts) treats SIGTERM as a stop signal — it shuts down gracefully and exits. The process never performs an in-process restart. Systemd eventually restarts it via Restart=always after RestartSec=5, but this is a cold restart, not the intended graceful restart.

The correct restart path is SIGUSR1, which triggers a graceful in-process restart: drain active tasks, close the server, then re-initialize. This is what restartGatewayWithoutServiceManager() already does for unmanaged processes.

Fix

  1. systemd-unit.ts: Add ExecReload=/bin/kill -USR1 $MAINPID to the systemd unit template so systemctl reload sends SIGUSR1.
  2. systemd.ts: Change restartSystemdService() to try systemctl reload first (graceful SIGUSR1). Falls back to systemctl restart for older unit files that lack ExecReload.

Why macOS is unaffected

On macOS, restartLaunchAgent() uses launchctl kickstart -k, which kills and restarts the process externally. With KeepAlive=true, launchd handles the full lifecycle — the gateway does not need to self-restart.

Files Changed

  • src/daemon/systemd-unit.ts — Added ExecReload directive
  • src/daemon/systemd.ts — Prefer reload over restart
  • src/daemon/systemd.test.ts — Updated and added tests

Fixes #44490

Changed files

  • src/daemon/systemd-unit.ts (modified, +3/-0)
  • src/daemon/systemd.test.ts (modified, +41/-6)
  • src/daemon/systemd.ts (modified, +13/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

Description When running openclaw gateway restart, the Gateway service stops but fails to restart. Only a manual system restart (or computer reboot) restores the service.

Steps to reproduce

Run openclaw gateway restart Observe that the Gateway stops Wait - service does not automatically restart

Expected behavior

The Gateway should restart smoothly using SIGUSR1 signal (in-process restart).

Actual behavior

Gateway receives SIGTERM and shuts down completely No automatic restart occurs Logs show: [gateway] signal SIGTERM received instead of [gateway] signal SIGUSR1 received

OpenClaw version

版本 2026.3.8

Operating system

macOS 13.7.8 (22H730)

Install method

No response

Model

minimax-portal/MiniMax-M2.5

Provider / routing chain

minimax

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

The fix involves modifying the restart command to send the correct signal (SIGUSR1) to the Gateway service.

  • Stop the Gateway service manually using pkill -SIGTERM gateway (if it's still running)
  • Modify the openclaw gateway restart command to send SIGUSR1 instead of SIGTERM
  • Example code snippet to achieve this:
# Send SIGUSR1 signal to the Gateway service
pkill -SIGUSR1 gateway

Alternatively, you can modify the openclaw script to use SIGUSR1 by default:

# Edit the openclaw script (e.g., using nano or vim)
nano /path/to/openclaw/script

# Replace the line that sends SIGTERM with the following line:
pkill -SIGUSR1 gateway
  • Restart the Gateway service using the modified command or script

Verification

To verify that the fix worked, run the modified openclaw gateway restart command and check the logs for the correct signal reception:

[gateway] signal SIGUSR1 received

The Gateway service should now restart smoothly without requiring a manual system restart.

Extra Tips

  • Make sure to update the openclaw script to use the correct signal (SIGUSR1) to avoid similar issues in the future.
  • If you're using a custom init system or systemd, you may need to modify the service configuration to use SIGUSR1 instead of SIGTERM.

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

The Gateway should restart smoothly using SIGUSR1 signal (in-process restart).

Still need to ship something?

×6

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

Back to top recommendations

TRENDING