fix: pass sandbox name to start-services.sh in stop and status#591
fix: pass sandbox name to start-services.sh in stop and status#591phanisaimunipalli wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
`stop()` and `showStatus()` called `start-services.sh` without `SANDBOX_NAME`, so they always looked in `/tmp/nemoclaw-services-default/` for PID files regardless of the actual sandbox name. When the default sandbox is named anything other than "default", `nemoclaw stop` would report the bridge as not running (and not stop it) and `nemoclaw status` would show it as stopped even though the bridge was still alive. Apply the same registry-lookup and `SANDBOX_NAME` env prefix that `start()` already uses to both `stop()` and `showStatus()` so all three commands agree on which PIDDIR to inspect. Fixes NVIDIA#587. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bin/nemoclaw.js (1)
246-248: Consider extracting sandbox env-prefix construction into a shared helper.
start(),stop(), andshowStatus()now repeat the same safe-name/env assembly. Centralizing this reduces future drift risk.Refactor sketch
+function getSandboxEnvPrefix() { + const { defaultSandbox } = registry.listSandboxes(); + const safeName = defaultSandbox && /^[a-zA-Z0-9._-]+$/.test(defaultSandbox) + ? defaultSandbox + : null; + return safeName ? `SANDBOX_NAME="${safeName}" ` : ""; +} + async function start() { await ensureApiKey(); - const { defaultSandbox } = registry.listSandboxes(); - const safeName = defaultSandbox && /^[a-zA-Z0-9._-]+$/.test(defaultSandbox) ? defaultSandbox : null; - const sandboxEnv = safeName ? `SANDBOX_NAME="${safeName}"` : ""; - run(`${sandboxEnv} bash "${SCRIPTS}/start-services.sh"`); + run(`${getSandboxEnvPrefix()}bash "${SCRIPTS}/start-services.sh"`); } function stop() { - const { defaultSandbox } = registry.listSandboxes(); - const safeName = defaultSandbox && /^[a-zA-Z0-9._-]+$/.test(defaultSandbox) ? defaultSandbox : null; - const sandboxEnv = safeName ? `SANDBOX_NAME="${safeName}"` : ""; - run(`${sandboxEnv} bash "${SCRIPTS}/start-services.sh" --stop`); + run(`${getSandboxEnvPrefix()}bash "${SCRIPTS}/start-services.sh" --stop`); } function showStatus() { // Show sandbox registry const { sandboxes, defaultSandbox } = registry.listSandboxes(); @@ - const safeName = defaultSandbox && /^[a-zA-Z0-9._-]+$/.test(defaultSandbox) ? defaultSandbox : null; - const sandboxEnv = safeName ? `SANDBOX_NAME="${safeName}"` : ""; - run(`${sandboxEnv} bash "${SCRIPTS}/start-services.sh" --status`); + run(`${getSandboxEnvPrefix()}bash "${SCRIPTS}/start-services.sh" --status`); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/nemoclaw.js` around lines 246 - 248, The sandbox env-prefix assembly (safeName validation and SANDBOX_NAME="..." string) is duplicated in start(), stop(), and showStatus(); extract this into a single helper (e.g., getSandboxEnvPrefix or buildSandboxEnvPrefix) that accepts defaultSandbox, validates with /^[a-zA-Z0-9._-]+$/, and returns either the prefixed string (SANDBOX_NAME="...") or an empty string; update start(), stop(), and showStatus() to call that helper and use its return value in run(...) instead of reimplementing safeName and sandboxEnv locally to avoid drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bin/nemoclaw.js`:
- Around line 246-248: The sandbox env-prefix assembly (safeName validation and
SANDBOX_NAME="..." string) is duplicated in start(), stop(), and showStatus();
extract this into a single helper (e.g., getSandboxEnvPrefix or
buildSandboxEnvPrefix) that accepts defaultSandbox, validates with
/^[a-zA-Z0-9._-]+$/, and returns either the prefixed string (SANDBOX_NAME="...")
or an empty string; update start(), stop(), and showStatus() to call that helper
and use its return value in run(...) instead of reimplementing safeName and
sandboxEnv locally to avoid drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 425a89cb-dd99-41b9-8ac9-2350d6795b1f
📒 Files selected for processing (1)
bin/nemoclaw.js
Summary
nemoclaw stopandnemoclaw statusalways looked in/tmp/nemoclaw-services-default/for PID files, regardless of the actual sandbox name.nemoclaw startcorrectly passesSANDBOX_NAMEfrom the registry tostart-services.sh, butstop()andshowStatus()did not."default",nemoclaw stopreports the bridge as not running (and skips stopping it) andnemoclaw statusshows it as stopped even though the bridge is alive.Root cause
start-services.shcomputesPIDDIR="/tmp/nemoclaw-services-${SANDBOX_NAME}". IfSANDBOX_NAMEis unset, it defaults to"default".stop()andshowStatus()innemoclaw.jsdid not setSANDBOX_NAME, so they always defaulted to/tmp/nemoclaw-services-default/, creating a mismatch with the directorystart()had written the PID files to.Fix
Apply the same registry-lookup and
SANDBOX_NAMEenv prefix thatstart()already uses to bothstop()andshowStatus():showStatus()already destructureddefaultSandboxfromregistry.listSandboxes()for the sandbox list display, so the fix there is just two additional lines before therun()call.Fixes #587.
🤖 Generated with Claude Code
Summary by CodeRabbit
stopandstatuscommands to properly retrieve and validate the default sandbox configuration before execution, ensuring more reliable command behavior.