feat: Add backend container startup script.
This commit is contained in:
parent
f81e394005
commit
c704aa8622
@ -8,9 +8,12 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
export HOME="/home/foxy"
|
||||
export FOXY_HOME="/home/foxy/.openclaw"
|
||||
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 "📌 FOXY_HOME = $FOXY_HOME"
|
||||
echo "📌 OPENCLAW_TYPE = $OPENCLAW_TYPE"
|
||||
echo "📌 FOXY_HOME = $FOXY_HOME"
|
||||
echo "📌 OPENCLAW_GATEWAY_BIND = $OPENCLAW_GATEWAY_BIND"
|
||||
|
||||
# ─── Ensure directories ──────────────────────────────────────────────────────
|
||||
mkdir -p "$FOXY_HOME/logs" "$FOXY_HOME/workspace" "$FOXY_HOME/agents"
|
||||
@ -28,35 +31,42 @@ echo "✅ Path patching complete."
|
||||
if [ "$OPENCLAW_TYPE" = "standalone" ]; then
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
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).
|
||||
# --bind lan : listen on all interfaces (required for Docker port mapping)
|
||||
# --port 18789 : explicit port
|
||||
nohup openclaw gateway run --bind lan --port 18789 > "$FOXY_HOME/logs/gateway.log" 2>&1 &
|
||||
# 'gateway run' = foreground mode (no systemd needed)
|
||||
# '--bind lan' = listen on all interfaces (0.0.0.0) for Docker port mapping
|
||||
# '--allow-unconfigured' = start even if gateway.mode!=local in config
|
||||
nohup openclaw gateway run \
|
||||
--bind lan \
|
||||
--allow-unconfigured \
|
||||
> "$FOXY_HOME/logs/gateway.log" 2>&1 &
|
||||
GATEWAY_PID=$!
|
||||
|
||||
echo "⏱ Waiting for Gateway (PID $GATEWAY_PID) to initialize..."
|
||||
sleep 5
|
||||
|
||||
if kill -0 $GATEWAY_PID 2>/dev/null; then
|
||||
echo "✅ OpenClaw Gateway is running (PID $GATEWAY_PID)."
|
||||
if netstat -tulpn 2>/dev/null | grep -q 18789; then
|
||||
echo "✅ Port 18789 is listening."
|
||||
else
|
||||
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
|
||||
|
||||
# Wait up to 15 seconds for port 18789 to open
|
||||
for i in $(seq 1 15); do
|
||||
if netstat -tulpn 2>/dev/null | grep -q ":18789"; then
|
||||
echo "✅ OpenClaw Gateway is UP — port 18789 is listening!"
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "❌ OpenClaw Gateway failed to start!"
|
||||
echo "──── Gateway Log ────"
|
||||
tail -n 30 "$FOXY_HOME/logs/gateway.log" 2>/dev/null || echo "(no log)"
|
||||
echo "─────────────────────"
|
||||
echo "⚠️ Continuing without Gateway. API will still start."
|
||||
if ! kill -0 $GATEWAY_PID 2>/dev/null; then
|
||||
echo "❌ Gateway process died!"
|
||||
echo "──── Gateway Log ────"
|
||||
tail -n 30 "$FOXY_HOME/logs/gateway.log" 2>/dev/null || echo "(no log)"
|
||||
echo "─────────────────────"
|
||||
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
|
||||
else
|
||||
echo "🔗 OPENCLAW_TYPE is shared — expecting host-managed Gateway."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user