fix gateway restart outside systemd#72224
Conversation
Greptile SummaryThis PR fixes Confidence Score: 4/5PR is safe to merge; both findings are non-blocking style issues with no impact on correctness. No P0 or P1 issues found. Two P2 findings: dead code in the isGatewayArgv return expression, and a redundant double-read of config/auth on the unmanaged restart path. Core logic for /proc inspection, ss fallback, and auth threading looks correct and is well-tested. src/infra/gateway-process-argv.ts (dead code on line 67), src/cli/daemon-cli/lifecycle.ts (duplicate config/auth resolution) Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/gateway-process-argv.ts
Line: 67
Comment:
**Dead code: `|| isGatewayBinary` is always `false` here**
`isGatewayBinary` is computed at lines 43–45 and consumed by the early-return guard at lines 47–49. Any execution that reaches line 67 has already established that `isGatewayBinary === false`, making the trailing `|| isGatewayBinary` unreachable and misleading.
```suggestion
return exe.endsWith("/openclaw") || exe === "openclaw";
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/cli/daemon-cli/lifecycle.ts
Line: 200-206
Comment:
**Duplicate config read and auth resolution on the unmanaged restart path**
When `restartGatewayWithoutServiceManager` is taken (lines 218–222), `assertUnmanagedGatewayRestartEnabled` (lines 82–109) already calls `readBestEffortConfig()` and `resolveDaemonProbeAuth` independently to build the pre-SIGUSR1 probe auth. This outer block then repeats the same two async calls to produce `restartProbeAuth` for the post-restart health check. Because the same config file is read twice and the same auth resolution module is loaded twice, any latency or transient error is doubled on the hot path.
Passing `restartProbeAuth` (or the resolved `cfg`) into `restartGatewayWithoutServiceManager` → `assertUnmanagedGatewayRestartEnabled` would let both steps share a single resolution.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix gateway restart outside systemd" | Re-trigger Greptile |
|
Follow-up pushed for review comments: removed the dead branch in \ and collapsed unmanaged restart config/auth lookup to a single shared resolution path in . Re-ran targeted tests and \ ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND No package.json (or package.yaml, or package.json5) was found in "/config".. |
|
Follow-up pushed for review comments. Changes:
Verification:
|
|
Addressed the review follow-ups in commit Updated:
Re-verified with:
|
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 5:50 AM ET / 09:50 UTC. Summary PR surface: Source +254, Tests +176. Total +430 across 10 files. Reproducibility: yes. source-level: current main and Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Refresh the PR onto current main, preserve protected-PID exclusions in every listener backend, fix the probe-auth test mock types, and attach redacted Linux no-systemd/no-lsof runtime proof before merge. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main and Is this the best way to solve the issue? No, not in the current branch state: the fix direction is plausible, but the branch must be refreshed, preserve protected-PID safety, pass type checks, and include real behavior proof before it is the best fix to land. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 36dd9ee3c3c1. Label changesLabel justifications:
Evidence reviewedPR surface: Source +254, Tests +176. Total +430 across 10 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…/ re-bootstrap) openclaw gateway restart relies on systemctl --user (src/daemon/systemd.ts:354) which is not present in the official ghcr.io/openclaw/openclaw:latest image. Until upstream openclaw/openclaw#72224 lands, document three working alternatives in the Troubleshooting section: SIGUSR1 to the live pid via docker exec for hot reload, docker restart for a clean cycle, full bootstrap re-run as last resort.
|
+1 from independent reproduction — flagging this PR also fixes #72948 (gateway stop foreground no-op), not just the restart side. I retested #72948 against Independent reproduction (same fix path, different symptom)Setup on Ubuntu 24.04, no systemd / no service manager: mkdir -p /tmp/openclaw-stop-test && cd /tmp/openclaw-stop-test
npm install [email protected]
export PATH="$PWD/node_modules/.bin:$PATH"
# Terminal A
openclaw gateway run --dev --port 38789
# Terminal B
ss -ltnp | grep 38789 # listener present
openclaw gateway stop # prints "Gateway service disabled."
ss -ltnp | grep 38789 # still boundConfirmed the verifier was the load-bearing piece via: xxd /proc/$(pgrep -f openclaw-gateway | head -1)/cmdline
# 00000000: 6f70 656e 636c 6177 2d67 6174 6577 6179 openclaw-gateway
# 00000010: 0000 0000 0000 0000 0000 ...
Two notes for whoever reviews
Happy to retest end-to-end against the rebased branch (Linux + container, no systemd) once it's green and re-confirm both #72223 and #72948 reproduce-then-resolve. Just ping me here. |
|
Branch refreshed again. Current state:
Local verification on this clean branch:
I did not rerun a containerized no-systemd/no-lsof smoke in this environment, so that remains the only proof gap called out from the earlier review thread. |
|
@myagizmaktav thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix gateway restart outside systemd This is item 1/1 in the current shard. Shard 10/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Closes #72223
Summary
/procinspection before falling back tolsofandssopenclaw-gatewayprocess titles as verified gateway processes for unmanaged restart signalingTesting
node openclaw.mjs gateway restart --jsonnow returnsresult: "restarted"while the gateway is running in the background