refactor(openclaw): remove REST facade (port 8004), unify on WebSocket

Remove the redundant OpenClaw REST service (port 8004) since frontend
already uses WebSocket via Gateway (port 8765) → OpenClaw (port 18789).

Deleted:
- backend/apps/openclaw_service.py
- backend/api/openclaw.py
- backend/tests/test_openclaw_service_app.py
- backend/tests/test_service_clients.py
- shared/client/openclaw_client.py

Updated:
- backend/apps/__init__.py — remove openclaw_app exports
- backend/api/__init__.py — remove openclaw_router
- shared/client/__init__.py — remove OpenClawServiceClient
- backend/services/gateway_openclaw_handlers.py — update docstring
- start.sh — remove port 8004 service startup

Architecture:
- Before: Frontend → HTTP :8004 → subprocess openclaw CLI
- After: Frontend → WS :8765 → Gateway → WS :18789 → OpenClaw

Constraint: Frontend already uses WebSocket exclusively
Confidence: high
Scope-risk: low (frontend unchanged)
This commit is contained in:
2026-04-02 11:04:06 +08:00
parent 45c3996434
commit ecc7623093
10 changed files with 4 additions and 1625 deletions

View File

@@ -149,7 +149,7 @@ kill_port() {
do_stop() {
echo -e "${CYAN}停止所有服务...${NC}"
for svc in frontend agent_service trading_service news_service runtime_service openclaw_service; do
for svc in frontend agent_service trading_service news_service runtime_service; do
stop_service "${svc}"
done
echo -e "${GREEN}已停止${NC}"
@@ -162,7 +162,6 @@ do_status() {
print_status "trading_service" 8001
print_status "news_service" 8002
print_status "runtime_service" 8003
print_status "openclaw_service" 8004
print_status "frontend" "${FRONTEND_PORT}"
echo ""
echo -e " ${CYAN}${NC} Gateway 由 runtime_service 管理,通过前端启动任务触发"
@@ -214,7 +213,6 @@ start_daemon() {
start_single_daemon "trading_service" "backend.apps.trading_service:app" 8001
start_single_daemon "news_service" "backend.apps.news_service:app" 8002
start_single_daemon "runtime_service" "backend.apps.runtime_service:app" 8003
start_single_daemon "openclaw_service" "backend.apps.openclaw_service:app" 8004
fi
echo -e " ${GREEN}${NC} frontend → http://0.0.0.0:${FRONTEND_PORT}"
@@ -268,7 +266,6 @@ start_foreground() {
start_single_foreground "trading_service" "backend.apps.trading_service:app" 8001
start_single_foreground "news_service" "backend.apps.news_service:app" 8002
start_single_foreground "runtime_service" "backend.apps.runtime_service:app" 8003
start_single_foreground "openclaw_service" "backend.apps.openclaw_service:app" 8004
fi
echo -e " ${GREEN}${NC} frontend → http://0.0.0.0:${FRONTEND_PORT}"
@@ -292,13 +289,12 @@ do_start() {
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:8004}"
build_frontend
echo ""
echo -e "${CYAN}停止已有服务...${NC}"
for svc in frontend agent_service trading_service news_service runtime_service openclaw_service; do
for svc in frontend agent_service trading_service news_service runtime_service; do
stop_service "${svc}"
done