Skip to content

feat(cli): add nemoclaw reconnect command for post-reboot recovery #910

Description

@prekshivyas

Description

After a host reboot, users must manually run multiple commands to reconnect to their sandbox: start Docker, restart the OpenShell gateway, check sandbox state, then connect. This is documented in the troubleshooting guide but could be a single command.

A nemoclaw reconnect command would automate the recovery sequence:

  1. Verify the container runtime is running
  2. Start the OpenShell gateway if it's not running (openshell gateway start --name nemoclaw)
  3. Wait for the gateway to become healthy
  4. Check sandbox state (openshell sandbox list)
  5. Start port forward and connect to the default (or named) sandbox

Context

Open questions

  • Does openshell gateway start --name nemoclaw work correctly when the gateway container exists but is stopped? Or does it require a destroy/recreate cycle?
  • Is the CoreDNS fix needed again after a reboot, or only on first setup?
  • Should this be a new nemoclaw reconnect command, or should nemoclaw <name> connect be smarter about detecting and recovering from a stopped gateway?

Suggested implementation

async function reconnect(sandboxName) {
  // 1. Check gateway
  const gwInfo = runCaptureOpenshell(["gateway", "info", "-g", "nemoclaw"], { ignoreError: true });
  if (!gwInfo || !gwInfo.includes("Running")) {
    console.log("  Starting OpenShell gateway...");
    runOpenshell(["gateway", "start", "--name", "nemoclaw"]);
    // wait for health
  }
  // 2. Find sandbox
  const name = sandboxName || registry.listSandboxes().defaultSandbox;
  if (!name) {
    console.error("  No sandbox registered. Run `nemoclaw onboard` first.");
    process.exit(1);
  }
  // 3. Connect
  sandboxConnect(name);
}

Related

Activity

  1. WuKongAI-CMU commented on Mar 26, 2026

    @WuKongAI-CMU
    Contributor

    Opened PR #960 to add a global nemoclaw reconnect [name] command that reuses the existing gateway recovery and sandbox connect path for post-reboot recovery.

  2. dknos commented on Mar 30, 2026

    @dknos
    Contributor

    Full post-reboot recovery script + systemd auto-start on WSL2

    Until a nemoclaw reconnect command exists, here's a complete startup script we use that handles the full recovery sequence automatically on every boot.

    ~/start-all.sh — handles:

    1. Waits for Docker + OpenShell gateway to be ready (retry loop, up to 5 min)
    2. Starts the sandbox if not running
    3. Waits for sandbox to reach Ready state (retry loop, up to 3 min)
    4. Clears stale session lock files
    5. Re-sets the inference provider (survives sandbox recreates)
    6. Restores custom files (skills, env, model config) via SSH
    7. Starts bridge processes via pm2
    #!/usr/bin/env bash
    set -uo pipefail
    
    source "$HOME/.nemoclaw_env"
    SANDBOX="${SANDBOX_NAME:-my-assistant}"
    
    # Wait for Docker + OpenShell gateway
    for i in $(seq 1 30); do
      if openshell gateway status 2>/dev/null | grep -qiE "running|ready|ok"; then break; fi
      if docker info >/dev/null 2>&1; then break; fi
      echo "($i/30) Docker not ready — waiting 10s..."
      sleep 10
    done
    
    # Start sandbox if not running
    nemoclaw status --json 2>/dev/null | grep -q '"running":true' || nemoclaw start 2>/dev/null &
    
    # Wait for sandbox ready
    for i in $(seq 1 36); do
      nemoclaw status --json 2>/dev/null | grep -q '"running":true' && break
      echo "($i/36) Sandbox not ready — waiting 5s..."
      sleep 5
    done
    
    # Clear stale lock files
    SSH_CONF=$(mktemp); openshell sandbox ssh-config "$SANDBOX" > "$SSH_CONF"
    ssh -T -F "$SSH_CONF" "openshell-${SANDBOX}" \
      'find /sandbox/.openclaw-data -name "*.lock" -delete 2>/dev/null'
    rm -f "$SSH_CONF"
    
    # Re-set inference
    openshell inference set --provider your-provider --model your-model --no-verify 2>/dev/null || true
    
    # Start bridges
    pm2 start ecosystem.config.js
    pm2 save

    Auto-start on WSL boot via systemd user service (~/.config/systemd/user/nemoclaw.service):

    [Unit]
    Description=NemoClaw AI Assistant
    After=network.target
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/home/%u/start-all.sh
    TimeoutStartSec=600
    
    [Install]
    WantedBy=default.target

    Enable with:

    systemctl --user enable nemoclaw.service
    loginctl enable-linger $USER

    This gives full hands-off recovery after every reboot — no manual steps needed.

  3. self-assigned this
    on Apr 23, 2026
  4. prekshivyas commented on May 5, 2026

    @prekshivyas
    CollaboratorAuthor

    Closing as resolved via a different approach. The top-level nemoclaw reconnect command proposed here was explicitly considered and rejected in PR #960 (closed unmerged 2026-03-31). Instead, PR #1187 (merged same day) placed recovery directly on the nemoclaw <name> connect path.

    What #1187 ships: when local registry state is missing or stale, nemoclaw <name> connect automatically probes openshell sandbox list, re-registers any live sandboxes it finds, clears stale SSH host keys on identity drift, and falls into connect — no separate command needed. Adjacent fixes #1466, #1087, #2064, and #1025 cover sandbox survival across gateway restarts, SSH key cleanup, identity drift, and proxy env persistence respectively.

    Verified locally today: wiping the local registry entry for a sandbox and running nemoclaw <sandbox> connect triggered the live gateway probe, re-registered a running sandbox automatically, and returned the correct error for one that wasn't live. The recovery mechanism from #1187 addresses the scenario this issue described.

  5. added
    area: cli
    area: install
    area: onboarding
    enhancement
    and removed on Jun 3, 2026
  6. removed
    enhancement
    on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cliarea: installarea: onboarding

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions