mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-10 04:09:40 +00:00
Fixes #1354 - users experienced a ~30s delay with "gateway not connected" errors when trying to use OpenClaw immediately after launch. Root cause: gateway takes time to bind to port 18789, but TUI launched after only 2 seconds. Solution: Add wait_for_openclaw_gateway() helper that polls the gateway port (max 30s) before launching TUI, ensuring immediate usability. Changes: - shared/common.sh: Add wait_for_openclaw_gateway() function - All openclaw.sh scripts (10 files): Replace sleep 2 with gateway readiness check Agent: ux-engineer Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
33 lines
1.2 KiB
Bash
Executable file
33 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
set -eo pipefail
|
|
|
|
# Source common functions - try local file first, fall back to remote
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
# shellcheck source=hetzner/lib/common.sh
|
|
if [[ -f "${SCRIPT_DIR}/lib/common.sh" ]]; then
|
|
source "${SCRIPT_DIR}/lib/common.sh"
|
|
else
|
|
eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/hetzner/lib/common.sh)"
|
|
fi
|
|
|
|
log_info "OpenClaw on Hetzner Cloud"
|
|
echo ""
|
|
|
|
AGENT_MODEL_PROMPT=1
|
|
AGENT_MODEL_DEFAULT="openrouter/auto"
|
|
|
|
agent_install() { install_agent "openclaw" "source ~/.bashrc && bun install -g openclaw" cloud_run; }
|
|
agent_env_vars() {
|
|
generate_env_config \
|
|
"OPENROUTER_API_KEY=${OPENROUTER_API_KEY}" \
|
|
"ANTHROPIC_API_KEY=${OPENROUTER_API_KEY}" \
|
|
"ANTHROPIC_BASE_URL=https://openrouter.ai/api"
|
|
}
|
|
agent_configure() { setup_openclaw_config "${OPENROUTER_API_KEY}" "${MODEL_ID}" cloud_upload cloud_run; }
|
|
agent_pre_launch() {
|
|
cloud_run "source ~/.zshrc && nohup openclaw gateway > /tmp/openclaw-gateway.log 2>&1 &"
|
|
wait_for_openclaw_gateway cloud_run
|
|
}
|
|
agent_launch_cmd() { echo 'source ~/.zshrc && openclaw tui'; }
|
|
|
|
spawn_agent "OpenClaw"
|