fix(tunnel): detect gateway with rewritten bare 'openclaw' argv (#4951)#4960
fix(tunnel): detect gateway with rewritten bare 'openclaw' argv (#4951)#4960abhi-0906 wants to merge 1 commit into
Conversation
…IA#4951) `nemoclaw tunnel stop` could not stop the in-sandbox gateway: OpenClaw rewrites its own argv via process.title after startup, so the running gateway shows just `openclaw` with no `gateway` suffix. The awk matcher in GATEWAY_STOP_SCRIPT only recognized `openclaw-gateway` and `openclaw gateway`, so find_gateway_pids returned empty, reportStopResult misread exit 1 as "not running", and the command exited 0 while the gateway (and its channel pollers) kept running. Add a third argv form to the matcher: a bare `openclaw` anchored to end-of-string (so it still rejects names like `openclawish`). The example argv tokens are kept out of the awk program text itself, because awk's argv is captured by the concurrent `ps` snapshot and any such literal would make awk match itself and prevent the scan from draining. Export GATEWAY_STOP_SCRIPT and add Linux-gated tests that execute it against real processes reproducing each argv form, asserting the bare gateway is killed (exit 0) and a non-gateway decoy is spared (exit 1). Signed-off-by: Abhimanyu Kumar <abhimanyukumar7290@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR exports the embedded ChangesGateway Stop Script Bug Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ Thanks for submitting this detailed PR about detecting the gateway with rewritten bare 'openclaw' argv. This proposes a way to fix the regression in the tunnel stop functionality. Related open issues: |
1 similar comment
|
✨ Thanks for submitting this detailed PR about detecting the gateway with rewritten bare 'openclaw' argv. This proposes a way to fix the regression in the tunnel stop functionality. Related open issues: |
Summary
nemoclaw tunnel stop(and its aliasnemoclaw stop) reported success and exited0while the in-sandbox OpenClaw gateway — and its channel pollers — kept running. The stop script's process matcher never found the gateway because OpenClaw rewrites its own argv to a bareopenclawafter startup. This teaches the matcher that third argv form so the gateway is actually detected and stopped.Related Issue
Fixes #4951
Root cause
stopSandboxChannelsruns an in-sandboxGATEWAY_STOP_SCRIPT(src/lib/tunnel/services.ts) whosefind_gateway_pidsscansps -eo args=and matches the gateway by argv. It recognized only:openclaw-gateway(the re-execed binary name), andopenclaw gateway run …(the launcher commandnemoclaw-startruns).But OpenClaw sets
process.title = 'openclaw'after startup, so the live gateway's argv is justopenclawwith nogatewaysuffix. As a resultfind_gateway_pidsreturned empty → the scriptexit 1→reportStopResultinterprets exit 1 as "gateway was not running" → the command prints success and exits0, leaving the gateway and Slack/Telegram/Discord pollers alive. (Sameprocess.titleroot cause as the sandbox HEALTHCHECK bug, NVB#6282411 / NVB#6282413.)Changes
src/lib/tunnel/services.ts— add a third argv form to thefind_gateway_pidsawk matcher: a bareopenclawanchored to end-of-string, so it still rejects unrelated names likeopenclawish. Document the three forms and why example argv tokens must stay out of the awk program body (awk's own argv is captured by the concurrentpssnapshot, so an in-program literal likeopenclaw gatewaymakes awk match itself and the kill/verify scan never drains). ExportGATEWAY_STOP_SCRIPTfor end-to-end testing.src/lib/tunnel/services-sandbox.test.ts— assert the matcher contains all three argv forms, and add two Linux-gated tests that execute the realGATEWAY_STOP_SCRIPTagainst live processes reproducing each argv form: the bare-argv gateway is found and killed (exit 0), and a non-gateway decoy is spared (exit 1).Type of Change
Verification
npx prek run --all-filespassesnpm testpassesnpm run docsbuilds without warnings (doc changes only)Ran locally on the affected files:
biome check(clean),tsc -p jsconfig.json(clean),vitest run src/lib/tunnel/services-sandbox.test.ts(17 passed, 2 Linux-gated execution tests skipped on the Windows dev box), plussource-shapeandtest-sizechecks. The two Linux-gated execution tests were validated against the compiled script on Ubuntu 24.04 (WSL): bareopenclawkilled → exit 0; decoy spared → exit 1.Summary by CodeRabbit
tunnel stopcommand to properly terminate all gateway processes. Previously, the command would exit successfully but leave certain gateway processes running in the background.