foxy-dev-team/backend/start-container.sh

65 lines
2.3 KiB
Bash

#!/bin/bash
set -e
echo "🦊 Starting Foxy Dev Team API Container..."
# Defaults if not provided
export FOXY_HOME="${FOXY_HOME:-/home/foxy/.openclaw}"
export OPENCLAW_TYPE="${OPENCLAW_TYPE:-shared}"
# Ensure logs directory exists
mkdir -p "$FOXY_HOME/logs"
if [ "$OPENCLAW_TYPE" = "standalone" ]; then
echo "🔧 OPENCLAW_TYPE is standalone. Setting up internal OpenClaw Gateway..."
# Initialize OpenClaw default configuration if it doesn't exist
if [ ! -f "$FOXY_HOME/config.json" ] && [ ! -f "$FOXY_HOME/config.yaml" ]; then
echo "📦 Initializing default OpenClaw config at $FOXY_HOME..."
mkdir -p "$FOXY_HOME/workspace"
mkdir -p "$FOXY_HOME/agents"
# Write a simple default config for Docker environment
cat <<EOF > "$FOXY_HOME/config.json"
{
"theme": "dark",
"logLevel": "info",
"gatewayPort": 18789,
"gatewayHost": "0.0.0.0",
"workspaceDir": "$FOXY_HOME/workspace",
"agentsDir": "$FOXY_HOME/agents"
}
EOF
echo "✅ Default configuration created (binding to 0.0.0.0)."
else
echo "👍 OpenClaw configuration already exists at $FOXY_HOME."
# Optional: ensure gatewayHost is 0.0.0.0 even in existing config if it's internal
fi
echo "🚀 Starting OpenClaw Gateway..."
# Launching the gateway. If 'start' backgrounds itself we might need 'run' or similar.
# We use 'nohup' but we'll check it's alive.
if command -v openclaw >/dev/null 2>&1; then
# Some versions of openclaw use 'gateway run' or just 'gateway' for foreground
nohup openclaw gateway start --host 0.0.0.0 > "$FOXY_HOME/logs/gateway.log" 2>&1 &
# Give it a second to start
sleep 2
if pgrep -f "openclaw" > /dev/null; then
echo "✅ OpenClaw Gateway started successfully."
else
echo "⚠️ Gateway didn't start with 'start' command, trying direct execution..."
# Fallback for some installations
nohup openclaw gateway > "$FOXY_HOME/logs/gateway.log" 2>&1 &
fi
else
echo "❌ 'openclaw' command not found!"
fi
else
echo "🔗 OPENCLAW_TYPE is shared. Assuming OpenClaw Gateway is managed by the host."
fi
echo "🚀 Starting Uvicorn API Server..."
exec python -m uvicorn app.main:app --host 0.0.0.0 --port 7000