feat: Add backend container startup script.

This commit is contained in:
Bruno Charest 2026-03-13 15:54:56 -04:00
parent f81e394005
commit c704aa8622

View File

@ -8,9 +8,12 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
export HOME="/home/foxy" export HOME="/home/foxy"
export FOXY_HOME="/home/foxy/.openclaw" export FOXY_HOME="/home/foxy/.openclaw"
export OPENCLAW_TYPE="${OPENCLAW_TYPE:-standalone}" export OPENCLAW_TYPE="${OPENCLAW_TYPE:-standalone}"
# Force gateway bind to LAN (all interfaces) — required for Docker
export OPENCLAW_GATEWAY_BIND="lan"
echo "📌 OPENCLAW_TYPE = $OPENCLAW_TYPE" echo "📌 OPENCLAW_TYPE = $OPENCLAW_TYPE"
echo "📌 FOXY_HOME = $FOXY_HOME" echo "📌 FOXY_HOME = $FOXY_HOME"
echo "📌 OPENCLAW_GATEWAY_BIND = $OPENCLAW_GATEWAY_BIND"
# ─── Ensure directories ────────────────────────────────────────────────────── # ─── Ensure directories ──────────────────────────────────────────────────────
mkdir -p "$FOXY_HOME/logs" "$FOXY_HOME/workspace" "$FOXY_HOME/agents" mkdir -p "$FOXY_HOME/logs" "$FOXY_HOME/workspace" "$FOXY_HOME/agents"
@ -28,35 +31,42 @@ echo "✅ Path patching complete."
if [ "$OPENCLAW_TYPE" = "standalone" ]; then if [ "$OPENCLAW_TYPE" = "standalone" ]; then
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🚀 Starting OpenClaw Gateway (standalone, foreground mode)..." echo "🚀 Starting OpenClaw Gateway (standalone, foreground mode)..."
echo ""
echo " Command: openclaw gateway run --bind lan --allow-unconfigured"
echo ""
# Use 'gateway run' (foreground) instead of 'gateway start' (systemd). # 'gateway run' = foreground mode (no systemd needed)
# --bind lan : listen on all interfaces (required for Docker port mapping) # '--bind lan' = listen on all interfaces (0.0.0.0) for Docker port mapping
# --port 18789 : explicit port # '--allow-unconfigured' = start even if gateway.mode!=local in config
nohup openclaw gateway run --bind lan --port 18789 > "$FOXY_HOME/logs/gateway.log" 2>&1 & nohup openclaw gateway run \
--bind lan \
--allow-unconfigured \
> "$FOXY_HOME/logs/gateway.log" 2>&1 &
GATEWAY_PID=$! GATEWAY_PID=$!
echo "⏱ Waiting for Gateway (PID $GATEWAY_PID) to initialize..." echo "⏱ Waiting for Gateway (PID $GATEWAY_PID) to initialize..."
sleep 5
if kill -0 $GATEWAY_PID 2>/dev/null; then # Wait up to 15 seconds for port 18789 to open
echo "✅ OpenClaw Gateway is running (PID $GATEWAY_PID)." for i in $(seq 1 15); do
if netstat -tulpn 2>/dev/null | grep -q 18789; then if netstat -tulpn 2>/dev/null | grep -q ":18789"; then
echo "✅ Port 18789 is listening." echo "✅ OpenClaw Gateway is UP — port 18789 is listening!"
else break
echo "⚠️ Port 18789 not yet open. Waiting 5 more seconds..."
sleep 5
if netstat -tulpn 2>/dev/null | grep -q 18789; then
echo "✅ Port 18789 is now listening."
else
echo "⚠️ Port still not open. Check: cat $FOXY_HOME/logs/gateway.log"
fi fi
fi if ! kill -0 $GATEWAY_PID 2>/dev/null; then
else echo "❌ Gateway process died!"
echo "❌ OpenClaw Gateway failed to start!"
echo "──── Gateway Log ────" echo "──── Gateway Log ────"
tail -n 30 "$FOXY_HOME/logs/gateway.log" 2>/dev/null || echo "(no log)" tail -n 30 "$FOXY_HOME/logs/gateway.log" 2>/dev/null || echo "(no log)"
echo "─────────────────────" echo "─────────────────────"
echo "⚠️ Continuing without Gateway. API will still start." break
fi
sleep 1
done
# Final check
if ! netstat -tulpn 2>/dev/null | grep -q ":18789"; then
echo "⚠️ Gateway may not be fully ready. Tail of log:"
tail -n 10 "$FOXY_HOME/logs/gateway.log" 2>/dev/null || true
echo "⚠️ Continuing anyway — API will still start."
fi fi
else else
echo "🔗 OPENCLAW_TYPE is shared — expecting host-managed Gateway." echo "🔗 OPENCLAW_TYPE is shared — expecting host-managed Gateway."