Skip to content

Fix systemd crash loop: forward SIGTERM during entry.ts respawn#933

Closed
roshanasingh4 wants to merge 1 commit intoopenclaw:mainfrom
roshanasingh4:fix/entry-respawn-signal-forwarding
Closed

Fix systemd crash loop: forward SIGTERM during entry.ts respawn#933
roshanasingh4 wants to merge 1 commit intoopenclaw:mainfrom
roshanasingh4:fix/entry-respawn-signal-forwarding

Conversation

@roshanasingh4
Copy link
Copy Markdown
Contributor

Fixes #931

Problem

src/entry.ts conditionally respawns itself to inject --disable-warning=ExperimentalWarning into NODE_OPTIONS. Today that respawn used spawnSync(), which blocks the parent process. When running under systemd with KillMode=process, systemctl stop only terminates the parent PID. The spawned child (the actual gateway process holding the port) can survive as an orphan and keep the gateway port bound, causing restart loops with EADDRINUSE.

Fix

Switch the respawn from spawnSync() to a non-blocking spawn() wrapper that forwards termination signals (SIGTERM/SIGINT/SIGHUP/SIGQUIT) from the parent to the child. This ensures a systemd stop will also terminate the actual gateway process even under KillMode=process.

Tests

Adds a regression test for the signal-forwarding helper that simulates the parent receiving SIGTERM and asserts the child process is terminated and releases its listening port.

@steipete steipete self-assigned this Jan 15, 2026
@steipete
Copy link
Copy Markdown
Contributor

Thanks Roshan!

@roshanasingh4
Copy link
Copy Markdown
Contributor Author

Thanks Roshan!

You're Welcome Peter...

steipete added a commit that referenced this pull request Jan 15, 2026
Co-authored-by: Roshan Singh <roshanasingh4@users.noreply.github.com>
@steipete steipete closed this Jan 15, 2026
@steipete
Copy link
Copy Markdown
Contributor

Landed on main after rebasing onto a temp branch.

What changed:

  • refactored respawn signal handling into a generic child-process bridge with cross-platform signal handling and error detach
  • switched the fixture to run under node directly (no tsx bin) and kept the regression test
  • added changelog entry

Tests: pnpm lint && pnpm build && pnpm test

Commits:

Thanks @roshanasingh4!

zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…ngh4)

Co-authored-by: Roshan Singh <roshanasingh4@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway crash loop: orphaned child process holds port after systemd stop

2 participants