-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·89 lines (73 loc) · 2.59 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·89 lines (73 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# AI Court 入口脚本
# 支持连接外部 OpenClaw 服务
set -e
echo "======================================"
echo " AI Court 启动"
echo "======================================"
# 检查是否使用外部 OpenClaw
if [ "$ENABLE_EXTERNAL_CLAW" = "true" ] || [ "$ENABLE_INTERNAL_CLAW" = "false" ]; then
echo "📡 模式:连接外部 OpenClaw 服务"
echo ""
# 验证外部 OpenClaw 配置
if [ -z "$OPENCLAW_HOST" ]; then
OPENCLAW_HOST="host.docker.internal"
echo "⚠️ OPENCLAW_HOST 未设置,使用默认值:$OPENCLAW_HOST"
fi
if [ -z "$OPENCLAW_PORT" ]; then
OPENCLAW_PORT="18789"
echo "⚠️ OPENCLAW_PORT 未设置,使用默认值:$OPENCLAW_PORT"
fi
echo "外部 OpenClaw 地址:http://$OPENCLAW_HOST:$OPENCLAW_PORT"
# 验证连接
echo "正在测试连接..."
if curl -f -s --connect-timeout 5 "http://$OPENCLAW_HOST:$OPENCLAW_PORT/health" > /dev/null 2>&1; then
echo "✅ 成功连接到外部 OpenClaw 服务"
else
echo "❌ 无法连接到外部 OpenClaw 服务"
echo " 请检查:"
echo " - OPENCLAW_HOST 是否正确"
echo " - OPENCLAW_PORT 是否正确"
echo " - 网络是否可达"
echo ""
echo "⚠️ 继续启动 GUI(仅 GUI 模式)..."
fi
# 设置环境变量供 GUI 使用
export CLAW_SERVER_URL="http://$OPENCLAW_HOST:$OPENCLAW_PORT"
if [ -n "$OPENCLAW_API_TOKEN" ]; then
export CLAW_API_TOKEN="$OPENCLAW_API_TOKEN"
fi
echo ""
echo "启动 GUI 服务器..."
echo "======================================"
# 只启动 GUI,不启动内部 OpenClaw
cd /opt/gui
exec node server/index.js
else
echo "🏠 模式:使用内部 OpenClaw 服务"
echo ""
# 启动内部 OpenClaw Gateway
echo "启动 OpenClaw Gateway..."
openclaw gateway --verbose &
# shellcheck disable=SC2034 # 保留 PID 供后续 trap/wait 用,exec node 后该变量自然失效
GATEWAY_PID=$!
# 等待 Gateway 启动
echo "等待 Gateway 就绪..."
for i in $(seq 1 30); do
if curl -f -s "http://localhost:18789/health" > /dev/null 2>&1; then
echo "✅ Gateway 已就绪"
break
fi
if [ $i -eq 30 ]; then
echo "❌ Gateway 启动超时"
exit 1
fi
sleep 1
done
echo ""
echo "启动 GUI 服务器..."
echo "======================================"
# 启动 GUI
cd /opt/gui
exec node server/index.js
fi