Files
evotraders/start-dev.sh
cillin 6ecc224427 feat: OpenClaw WebSocket integration with workspace file preview
- Migrate OpenClaw from HTTP (port 8004) to WebSocket (port 18789)
- Add workspace file list and content preview handlers
- Add OpenClawStatus component with agent/skills view
- Add OpenClawView panel in trader interface
- Add Zustand store for OpenClaw state management
- Fix gateway logging noise (yfinance, websockets)
- Fix RunWorkspaceManager.get_agent_asset_dir attribute error
- Handle missing workspace files gracefully in preview

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 11:08:15 +08:00

119 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# EvoTraders Development Startup Script
# Split-service mode only
set -e
echo "=========================================="
echo "EvoTraders Development Environment"
echo "=========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check virtual environment
if [ -z "$VIRTUAL_ENV" ]; then
echo -e "${YELLOW}Warning: Virtual environment not activated${NC}"
echo "Activating .venv..."
source .venv/bin/activate
fi
# Load environment variables
if [ -f .env ]; then
echo -e "${GREEN}Loading environment from .env${NC}"
export $(grep -v '^#' .env | xargs)
else
echo -e "${YELLOW}Warning: .env file not found${NC}"
fi
cd /Users/cillin/workspeace/evotraders
PIDS=()
start_service() {
local name="$1"
local app_path="$2"
local port="$3"
echo -e "${GREEN}Starting ${name}${NC} on port ${port}..."
SERVICE_NAME="${name}" python -m uvicorn "${app_path}" \
--host 0.0.0.0 \
--port "${port}" \
--reload \
--reload-dir backend \
--log-level warning \
--no-access-log &
PIDS+=($!)
}
cleanup() {
if [ "${#PIDS[@]}" -gt 0 ]; then
echo ""
echo -e "${YELLOW}Stopping development services...${NC}"
kill "${PIDS[@]}" 2>/dev/null || true
wait "${PIDS[@]}" 2>/dev/null || true
fi
}
kill_port() {
local port="$1"
local pids=$(lsof -ti :${port} 2>/dev/null || true)
if [ -n "$pids" ]; then
echo -e "${YELLOW}Port ${port} is in use, killing PID(s): ${pids}${NC}"
echo "$pids" | xargs kill -9 2>/dev/null || true
sleep 0.5
fi
}
trap cleanup EXIT INT TERM
if [ $# -gt 0 ]; then
echo -e "${YELLOW}Ignoring legacy mode argument(s): $*${NC}"
echo "Split-service mode is now the only supported development mode."
fi
export TRADING_SERVICE_URL="${TRADING_SERVICE_URL:-http://localhost:8001}"
export NEWS_SERVICE_URL="${NEWS_SERVICE_URL:-http://localhost:8002}"
export RUNTIME_SERVICE_URL="${RUNTIME_SERVICE_URL:-http://localhost:8003}"
export OPENCLAW_SERVICE_URL="${OPENCLAW_SERVICE_URL:-http://localhost:18789}"
echo ""
echo -e "${GREEN}Starting EvoTraders split services (default mode)...${NC}"
echo " agent_service: http://localhost:8000"
echo " runtime_service: http://localhost:8003"
echo " openclaw_gateway: ws://localhost:18789"
echo " trading_service: http://localhost:8001"
echo " news_service: http://localhost:8002"
echo ""
echo "Exported backend preference URLs:"
echo " TRADING_SERVICE_URL=${TRADING_SERVICE_URL}"
echo " NEWS_SERVICE_URL=${NEWS_SERVICE_URL}"
echo " RUNTIME_SERVICE_URL=${RUNTIME_SERVICE_URL}"
echo " OPENCLAW_SERVICE_URL=${OPENCLAW_SERVICE_URL}"
echo ""
echo -e "${GREEN}Checking ports...${NC}"
kill_port 8000
kill_port 8001
kill_port 8002
kill_port 8003
kill_port 8765
start_service "agent_service" "backend.apps.agent_service:app" 8000
start_service "runtime_service" "backend.apps.runtime_service:app" 8003
start_service "trading_service" "backend.apps.trading_service:app" 8001
start_service "news_service" "backend.apps.news_service:app" 8002
echo -e "${GREEN}Starting Gateway (WebSocket, port 8765)...${NC}"
SERVICE_NAME="gateway" python -m backend.main \
--mode live \
--host 0.0.0.0 \
--port 8765 &
PIDS+=($!)
echo -e "${GREEN}Split services are running.${NC}"
echo "Use Ctrl+C to stop all services."
wait