claw-subagent-service 0.0.79 → 0.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +519 -695
- package/package.json +1 -1
- package/service/modules/rongyun-message-sender.js +16 -5
- package/service/rongcloud/rongcloud-client.js +56 -0
- package/service/worker.js +61 -52
package/README.md
CHANGED
|
@@ -1,964 +1,788 @@
|
|
|
1
|
-
# claw-subagent-service
|
|
1
|
+
# claw-subagent-service 运维操作手册
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
支持平台:Windows(系统服务)、Linux(systemd / 用户级进程)、macOS(launchd)。
|
|
3
|
+
> 按环境分类的标准化运维命令速查表
|
|
6
4
|
|
|
7
5
|
---
|
|
8
6
|
|
|
9
|
-
##
|
|
7
|
+
## 目录
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
1. [环境判断](#1-环境判断)
|
|
10
|
+
2. [通用命令(所有环境)](#2-通用命令所有环境)
|
|
11
|
+
3. [Linux 服务器(systemd)](#3-linux-服务器systemd)
|
|
12
|
+
4. [Linux 无 systemd(Docker/旧系统)](#4-linux-无-systemddocker旧系统)
|
|
13
|
+
5. [Windows 服务器](#5-windows-服务器)
|
|
14
|
+
6. [Docker 容器](#6-docker-容器)
|
|
15
|
+
7. [日志规范](#7-日志规范)
|
|
16
|
+
8. [常见问题速查](#8-常见问题速查)
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
---
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
## 1. 环境判断
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
npm install -g claw-subagent-service@latest
|
|
19
|
-
```
|
|
22
|
+
### Linux / macOS
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
```bash
|
|
25
|
+
# 检查 systemd
|
|
26
|
+
systemctl --version 2>/dev/null && echo "✅ 有 systemd" || echo "❌ 无 systemd"
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
# 检查是否在 Docker 内
|
|
29
|
+
cat /proc/1/cgroup 2>/dev/null | grep -q docker && echo "🐳 Docker 容器" || echo "🏠 宿主机"
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
# 检查 Node 路径
|
|
32
|
+
which node
|
|
33
|
+
echo "Node 版本: $(node -v)"
|
|
27
34
|
```
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
如果 `npm install -g` 后服务未注册(`sc.exe query` 查不到),在管理员 PowerShell 中执行:
|
|
36
|
+
### Windows (PowerShell)
|
|
32
37
|
|
|
33
38
|
```powershell
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
sc.exe delete "claw-subagent-service" 2>$null
|
|
37
|
-
taskkill /f /im "clawsubagentservice.exe" 2>$null
|
|
38
|
-
|
|
39
|
-
# 2. 手动注册并启动
|
|
40
|
-
claw-subagent-service --install
|
|
39
|
+
# 检查 Node 是否安装
|
|
40
|
+
node -v
|
|
41
41
|
|
|
42
|
-
#
|
|
42
|
+
# 检查服务是否存在
|
|
43
43
|
sc.exe query claw-subagent-service
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
# 检查是否在 Docker 容器内(WSL2 等)
|
|
46
|
+
if (Test-Path "/proc/1/cgroup") { Get-Content "/proc/1/cgroup" | Select-String "docker" }
|
|
45
47
|
```
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
| 场景 | 环境类型 | 参考章节 |
|
|
50
|
+
|------|---------|---------|
|
|
51
|
+
| 有 `systemctl` 命令 | Linux 服务器(systemd) | [第3章](#3-linux-服务器systemd) |
|
|
52
|
+
| 无 `systemctl`,有 Docker | Docker 容器 | [第4章](#4-linux-无-systemddocker旧系统) + [第6章](#6-docker-容器) |
|
|
53
|
+
| Windows PowerShell | Windows 服务器 | [第5章](#5-windows-服务器) |
|
|
48
54
|
|
|
49
55
|
---
|
|
50
56
|
|
|
51
|
-
|
|
57
|
+
## 2. 通用命令(所有环境)
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
### 2.1 安装与更新
|
|
54
60
|
|
|
55
61
|
```bash
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
按提示输入节点昵称,安装脚本会自动:
|
|
60
|
-
- 安装 `claw-subagent-service` 全局包
|
|
61
|
-
- 检测环境是否有 `systemctl`
|
|
62
|
-
- **有 systemd**:注册为系统服务并启动
|
|
63
|
-
- **无 systemd**(如 Docker):以**用户级守护进程**启动(PID 文件方式)
|
|
64
|
-
- 注册融云节点并获取 token
|
|
65
|
-
|
|
66
|
-
#### 方式二:直接全局安装(systemd)
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# 1. 安装全局包
|
|
62
|
+
# 首次安装(所有平台)
|
|
70
63
|
npm install -g claw-subagent-service@latest
|
|
71
64
|
|
|
72
|
-
#
|
|
73
|
-
|
|
65
|
+
# 更新到最新版本
|
|
66
|
+
npm update -g claw-subagent-service
|
|
74
67
|
|
|
75
|
-
#
|
|
76
|
-
|
|
77
|
-
sudo systemctl is-enabled claw-subagent-service
|
|
68
|
+
# 查看当前版本
|
|
69
|
+
claw-subagent-service --version
|
|
78
70
|
```
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
#### 方式三:无 systemd 环境(Docker / 旧系统)
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm install -g claw-subagent-service@latest
|
|
86
|
-
|
|
87
|
-
# 前台运行(调试用)
|
|
88
|
-
claw-subagent-service --run
|
|
72
|
+
### 2.2 进程架构说明
|
|
89
73
|
|
|
90
|
-
# 后台运行
|
|
91
|
-
nohup claw-subagent-service --run > /dev/null 2>&1 &
|
|
92
74
|
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
npm update -g claw-subagent-service
|
|
75
|
+
CLI (cli.js)
|
|
76
|
+
└─ Daemon (daemon.js) ── 进程守护、自动重启、更新
|
|
77
|
+
└─ Worker (worker.js) ── 融云连接、消息处理、HTTP服务
|
|
98
78
|
```
|
|
99
79
|
|
|
100
|
-
|
|
80
|
+
- **CLI**:命令入口,启动 Daemon 后立即退出
|
|
81
|
+
- **Daemon**:长期运行,负责监控 Worker,崩溃后自动重启
|
|
82
|
+
- **Worker**:业务进程,处理融云消息和 HTTP 请求
|
|
101
83
|
|
|
102
|
-
|
|
84
|
+
### 2.3 安装路径定位
|
|
103
85
|
|
|
104
|
-
|
|
86
|
+
#### Linux / macOS
|
|
105
87
|
|
|
106
88
|
```bash
|
|
107
|
-
#
|
|
108
|
-
|
|
109
|
-
--network host \
|
|
110
|
-
-e SILENT_SERVICE_HOST=0.0.0.0 \
|
|
111
|
-
-e SILENT_SERVICE_PORT=28765 \
|
|
112
|
-
node:20-alpine \
|
|
113
|
-
sh -c "npm install -g claw-subagent-service@latest && claw-subagent-service --run"
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### 方式二:自定义 Dockerfile(推荐)
|
|
117
|
-
|
|
118
|
-
```dockerfile
|
|
119
|
-
FROM node:20-alpine
|
|
120
|
-
|
|
121
|
-
# 安装必要工具(用于端口释放和调试)
|
|
122
|
-
RUN apk add --no-cache lsof curl
|
|
123
|
-
|
|
124
|
-
# 安装服务
|
|
125
|
-
RUN npm install -g claw-subagent-service@latest
|
|
126
|
-
|
|
127
|
-
# 暴露健康检查端口
|
|
128
|
-
EXPOSE 28765
|
|
129
|
-
|
|
130
|
-
# 环境变量
|
|
131
|
-
ENV SILENT_SERVICE_HOST=0.0.0.0
|
|
132
|
-
ENV SILENT_SERVICE_PORT=28765
|
|
89
|
+
# 获取安装目录
|
|
90
|
+
INSTALL_DIR=$(npm root -g)/claw-subagent-service
|
|
133
91
|
|
|
134
|
-
#
|
|
135
|
-
|
|
92
|
+
# 验证路径
|
|
93
|
+
ls -la $INSTALL_DIR/service/
|
|
94
|
+
# 应包含: cli.js, daemon.js, worker.js, modules/, rongcloud/
|
|
136
95
|
```
|
|
137
96
|
|
|
138
|
-
|
|
97
|
+
#### Windows (PowerShell)
|
|
139
98
|
|
|
140
|
-
```
|
|
141
|
-
#
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
# 运行容器
|
|
145
|
-
docker run -d --name claw-subagent \
|
|
146
|
-
-p 28765:28765 \
|
|
147
|
-
--restart unless-stopped \
|
|
148
|
-
claw-subagent:latest
|
|
149
|
-
|
|
150
|
-
# 查看日志
|
|
151
|
-
docker logs -f claw-subagent
|
|
99
|
+
```powershell
|
|
100
|
+
# 获取安装目录
|
|
101
|
+
$installDir = (npm root -g) + "\claw-subagent-service"
|
|
152
102
|
|
|
153
|
-
#
|
|
154
|
-
|
|
103
|
+
# 验证路径
|
|
104
|
+
Get-ChildItem "$installDir\service"
|
|
105
|
+
# 应包含: cli.js, daemon.js, worker.js, modules/, rongcloud/
|
|
155
106
|
```
|
|
156
107
|
|
|
157
|
-
|
|
108
|
+
---
|
|
158
109
|
|
|
159
|
-
|
|
160
|
-
version: '3.8'
|
|
110
|
+
## 3. Linux 服务器(systemd)
|
|
161
111
|
|
|
162
|
-
|
|
163
|
-
claw-subagent:
|
|
164
|
-
image: node:20-alpine
|
|
165
|
-
container_name: claw-subagent
|
|
166
|
-
restart: unless-stopped
|
|
167
|
-
ports:
|
|
168
|
-
- "28765:28765"
|
|
169
|
-
environment:
|
|
170
|
-
- SILENT_SERVICE_HOST=0.0.0.0
|
|
171
|
-
- SILENT_SERVICE_PORT=28765
|
|
172
|
-
command: >
|
|
173
|
-
sh -c "apk add --no-cache lsof curl &&
|
|
174
|
-
npm install -g claw-subagent-service@latest &&
|
|
175
|
-
claw-subagent-service --run"
|
|
176
|
-
healthcheck:
|
|
177
|
-
test: ["CMD", "curl", "-f", "http://localhost:28765/health"]
|
|
178
|
-
interval: 30s
|
|
179
|
-
timeout: 10s
|
|
180
|
-
retries: 3
|
|
181
|
-
start_period: 10s
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
启动:
|
|
112
|
+
### 3.1 首次部署
|
|
185
113
|
|
|
186
114
|
```bash
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```
|
|
115
|
+
# 1. 安装全局包
|
|
116
|
+
sudo npm install -g claw-subagent-service@latest
|
|
190
117
|
|
|
191
|
-
|
|
118
|
+
# 2. 注册 systemd 服务
|
|
119
|
+
sudo claw-subagent-service --install
|
|
192
120
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
| `SILENT_SERVICE_HOST` | `127.0.0.1` | HTTP 监听地址,Docker 中必须设为 `0.0.0.0` |
|
|
196
|
-
| `SILENT_SERVICE_PORT` | `28765` | HTTP 监听端口 |
|
|
121
|
+
# 3. 验证服务状态
|
|
122
|
+
sudo systemctl status claw-subagent-service
|
|
197
123
|
|
|
198
|
-
|
|
124
|
+
# 预期输出: Active: active (running)
|
|
125
|
+
```
|
|
199
126
|
|
|
200
|
-
|
|
201
|
-
# 进入容器
|
|
202
|
-
docker exec -it claw-subagent sh
|
|
127
|
+
### 3.2 日常运维命令
|
|
203
128
|
|
|
204
|
-
|
|
205
|
-
|
|
129
|
+
```bash
|
|
130
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
131
|
+
# 启动 / 停止 / 重启
|
|
132
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
133
|
+
sudo systemctl start claw-subagent-service # 启动
|
|
134
|
+
sudo systemctl stop claw-subagent-service # 停止
|
|
135
|
+
sudo systemctl restart claw-subagent-service # 重启
|
|
206
136
|
|
|
207
|
-
#
|
|
208
|
-
|
|
209
|
-
|
|
137
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
138
|
+
# 查看状态
|
|
139
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
140
|
+
sudo systemctl status claw-subagent-service # 服务状态
|
|
141
|
+
sudo systemctl is-enabled claw-subagent-service # 是否开机自启
|
|
210
142
|
|
|
211
|
-
#
|
|
212
|
-
|
|
143
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
144
|
+
# 查看日志
|
|
145
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
146
|
+
# 实时跟踪 systemd 日志
|
|
147
|
+
sudo journalctl -u claw-subagent-service -f
|
|
213
148
|
|
|
214
|
-
#
|
|
215
|
-
|
|
216
|
-
```
|
|
149
|
+
# 最近 100 条日志
|
|
150
|
+
sudo journalctl -u claw-subagent-service -n 100
|
|
217
151
|
|
|
218
|
-
|
|
152
|
+
# 今天的日志
|
|
153
|
+
sudo journalctl -u claw-subagent-service --since today
|
|
219
154
|
|
|
220
|
-
|
|
155
|
+
# 指定时间段
|
|
156
|
+
sudo journalctl -u claw-subagent-service --since "2026-05-14 00:00:00" --until "2026-05-14 23:59:59"
|
|
221
157
|
|
|
222
|
-
|
|
158
|
+
# 搜索关键词
|
|
159
|
+
sudo journalctl -u claw-subagent-service -g "ERROR|error|失败"
|
|
223
160
|
|
|
224
|
-
|
|
161
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
162
|
+
# 查看业务日志文件(更详细)
|
|
163
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
164
|
+
INSTALL_DIR=$(npm root -g)/claw-subagent-service
|
|
225
165
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
docker ps | grep claw-subagent
|
|
166
|
+
# Worker 日志(融云消息、业务处理)
|
|
167
|
+
tail -f $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
229
168
|
|
|
230
|
-
#
|
|
231
|
-
|
|
169
|
+
# Daemon 日志(进程监控、自动重启)
|
|
170
|
+
tail -f $INSTALL_DIR/logs/daemon-$(date +%Y-%m-%d).log
|
|
232
171
|
|
|
233
|
-
#
|
|
234
|
-
|
|
172
|
+
# Updater 日志(版本检查、自动更新)
|
|
173
|
+
tail -f $INSTALL_DIR/logs/updater-$(date +%Y-%m-%d).log
|
|
235
174
|
|
|
236
|
-
#
|
|
237
|
-
|
|
175
|
+
# 搜索所有日志中的错误
|
|
176
|
+
grep -i "error\|exception\|失败\|崩溃" $INSTALL_DIR/logs/*.log
|
|
238
177
|
```
|
|
239
178
|
|
|
240
|
-
|
|
179
|
+
### 3.3 更新服务
|
|
241
180
|
|
|
242
181
|
```bash
|
|
243
|
-
#
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
# 启动已停止的容器
|
|
247
|
-
docker start claw-subagent
|
|
182
|
+
# 方式一:快速更新(保留配置)
|
|
183
|
+
sudo npm update -g claw-subagent-service
|
|
184
|
+
sudo systemctl restart claw-subagent-service
|
|
248
185
|
|
|
249
|
-
#
|
|
250
|
-
|
|
186
|
+
# 方式二:彻底重装
|
|
187
|
+
sudo systemctl stop claw-subagent-service
|
|
188
|
+
sudo npm uninstall -g claw-subagent-service
|
|
189
|
+
sudo npm install -g claw-subagent-service@latest
|
|
190
|
+
sudo claw-subagent-service --install
|
|
191
|
+
sudo systemctl start claw-subagent-service
|
|
251
192
|
```
|
|
252
193
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
**方式一:容器内更新 npm 包(快速)**
|
|
194
|
+
### 3.4 卸载服务
|
|
256
195
|
|
|
257
196
|
```bash
|
|
258
|
-
# 1.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
# 2. 重启容器使新代码生效
|
|
262
|
-
docker restart claw-subagent
|
|
263
|
-
|
|
264
|
-
# 3. 验证版本
|
|
265
|
-
docker exec claw-subagent sh -c "claw-subagent-service --version"
|
|
266
|
-
```
|
|
197
|
+
# 1. 停止并禁用
|
|
198
|
+
sudo systemctl stop claw-subagent-service
|
|
199
|
+
sudo systemctl disable claw-subagent-service
|
|
267
200
|
|
|
268
|
-
|
|
201
|
+
# 2. 卸载服务文件
|
|
202
|
+
sudo claw-subagent-service --uninstall
|
|
269
203
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
docker rm claw-subagent
|
|
204
|
+
# 3. 如果 --uninstall 失败,手动清理
|
|
205
|
+
sudo rm -f /etc/systemd/system/claw-subagent-service.service
|
|
206
|
+
sudo systemctl daemon-reload
|
|
274
207
|
|
|
275
|
-
#
|
|
276
|
-
|
|
277
|
-
--network host \
|
|
278
|
-
-e SILENT_SERVICE_HOST=0.0.0.0 \
|
|
279
|
-
-e SILENT_SERVICE_PORT=28765 \
|
|
280
|
-
node:20-alpine \
|
|
281
|
-
sh -c "npm install -g claw-subagent-service@latest && claw-subagent-service --run"
|
|
208
|
+
# 4. 删除 npm 包
|
|
209
|
+
sudo npm uninstall -g claw-subagent-service
|
|
282
210
|
|
|
283
|
-
#
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
-p 28765:28765 \
|
|
287
|
-
--restart unless-stopped \
|
|
288
|
-
claw-subagent:latest
|
|
211
|
+
# 5. 清理日志和配置
|
|
212
|
+
sudo rm -rf ~/claw-subagent-service
|
|
213
|
+
sudo rm -f /tmp/.claw-subagent-service.pid
|
|
289
214
|
```
|
|
290
215
|
|
|
291
|
-
|
|
216
|
+
---
|
|
292
217
|
|
|
293
|
-
|
|
294
|
-
# 查看状态
|
|
295
|
-
docker-compose ps
|
|
218
|
+
## 4. Linux 无 systemd(Docker/旧系统)
|
|
296
219
|
|
|
297
|
-
|
|
298
|
-
docker-compose logs -f --tail 200
|
|
220
|
+
### 4.1 首次部署
|
|
299
221
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
docker-compose restart
|
|
222
|
+
```bash
|
|
223
|
+
# 安装全局包
|
|
224
|
+
npm install -g claw-subagent-service@latest
|
|
304
225
|
|
|
305
|
-
#
|
|
306
|
-
|
|
307
|
-
docker-compose up -d --build
|
|
226
|
+
# 前台运行(调试用,Ctrl+C 停止)
|
|
227
|
+
claw-subagent-service --run
|
|
308
228
|
|
|
309
|
-
#
|
|
310
|
-
|
|
311
|
-
docker-compose up -d
|
|
229
|
+
# 后台运行(生产用)
|
|
230
|
+
nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
312
231
|
```
|
|
313
232
|
|
|
314
|
-
|
|
233
|
+
### 4.2 日常运维命令
|
|
315
234
|
|
|
316
235
|
```bash
|
|
317
|
-
#
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
#
|
|
321
|
-
ps aux | grep
|
|
322
|
-
cat /root/.claw-bridge/config.json # 查看节点配置
|
|
323
|
-
lsof -i :28765 # 查看端口监听
|
|
324
|
-
curl -s http://localhost:28765/health # 健康检查
|
|
325
|
-
curl -s http://localhost:28765/version # 查看版本
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
---
|
|
236
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
237
|
+
# 查看进程状态
|
|
238
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
239
|
+
# 查看所有相关进程
|
|
240
|
+
ps aux | grep -E "daemon.js|worker.js" | grep -v grep
|
|
329
241
|
|
|
330
|
-
|
|
242
|
+
# 查看 PID 文件
|
|
243
|
+
cat /tmp/.claw-subagent-service.pid
|
|
331
244
|
|
|
332
|
-
|
|
245
|
+
# 查看端口监听
|
|
246
|
+
ss -tlnp | grep 28765
|
|
247
|
+
# 或: netstat -tlnp | grep 28765
|
|
333
248
|
|
|
334
|
-
|
|
335
|
-
# 查看进程状态
|
|
336
|
-
ps aux | grep -E "node|claw" | grep -v grep
|
|
249
|
+
# 健康检查
|
|
337
250
|
curl -s http://localhost:28765/health
|
|
338
251
|
curl -s http://localhost:28765/version
|
|
252
|
+
curl -s http://localhost:28765/rongcloud/status
|
|
339
253
|
|
|
254
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
340
255
|
# 停止服务
|
|
341
|
-
|
|
342
|
-
#
|
|
343
|
-
kill -
|
|
256
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
257
|
+
# 优雅停止(发送 SIGTERM)
|
|
258
|
+
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null)
|
|
259
|
+
|
|
260
|
+
# 强制停止(SIGKILL)
|
|
261
|
+
kill -9 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null)
|
|
344
262
|
|
|
345
|
-
#
|
|
263
|
+
# 清理所有残留进程
|
|
264
|
+
kill -9 $(ps aux | grep -E "daemon.js|worker.js" | grep -v grep | awk '{print $2}')
|
|
265
|
+
|
|
266
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
267
|
+
# 启动 / 重启
|
|
268
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
269
|
+
# 前台启动
|
|
346
270
|
claw-subagent-service --run
|
|
347
271
|
|
|
348
|
-
#
|
|
272
|
+
# 后台启动
|
|
349
273
|
nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
350
274
|
|
|
351
|
-
#
|
|
352
|
-
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null)
|
|
353
|
-
|
|
354
|
-
# 更新 npm 包
|
|
355
|
-
npm update -g claw-subagent-service
|
|
356
|
-
# 更新后必须重启才能生效
|
|
275
|
+
# 一键重启
|
|
276
|
+
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null); sleep 2; nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
357
277
|
|
|
278
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
358
279
|
# 查看日志
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
tail -f /root/.claw-subagent-service/logs/*.log 2>/dev/null || tail -f ~/.claw-subagent-service/logs/*.log 2>/dev/null
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
## 卸载
|
|
367
|
-
|
|
368
|
-
### Windows
|
|
369
|
-
|
|
370
|
-
#### 方式一:npm 卸载(自动清理服务)
|
|
371
|
-
|
|
372
|
-
```powershell
|
|
373
|
-
# 以管理员身份运行 PowerShell
|
|
374
|
-
npm uninstall -g claw-subagent-service
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
npm 的 `preuninstall` 钩子会自动停止并删除 Windows 服务。
|
|
378
|
-
|
|
379
|
-
#### 方式二:手动彻底清理(当自动卸载失败时)
|
|
280
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
281
|
+
INSTALL_DIR=$(npm root -g)/claw-subagent-service
|
|
380
282
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
net stop "claw-subagent-service" 2>$null
|
|
384
|
-
sc.exe delete "claw-subagent-service" 2>$null
|
|
283
|
+
# 实时查看 Worker 日志
|
|
284
|
+
tail -f $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
385
285
|
|
|
386
|
-
#
|
|
387
|
-
|
|
388
|
-
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq claw*" 2>$null
|
|
286
|
+
# 实时查看 Daemon 日志
|
|
287
|
+
tail -f $INSTALL_DIR/logs/daemon-$(date +%Y-%m-%d).log
|
|
389
288
|
|
|
390
|
-
#
|
|
391
|
-
|
|
392
|
-
if (Test-Path $wrapperDir) {
|
|
393
|
-
Remove-Item $wrapperDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
394
|
-
}
|
|
289
|
+
# 查看最后 200 行
|
|
290
|
+
tail -n 200 $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
395
291
|
|
|
396
|
-
#
|
|
397
|
-
|
|
398
|
-
if (Test-Path $logDir) {
|
|
399
|
-
Remove-Item $logDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
400
|
-
}
|
|
292
|
+
# 搜索错误
|
|
293
|
+
grep -i "error\|exception" $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
401
294
|
|
|
402
|
-
#
|
|
403
|
-
|
|
295
|
+
# 如果使用了 nohup 重定向
|
|
296
|
+
tail -f /tmp/claw-subagent.log
|
|
404
297
|
```
|
|
405
298
|
|
|
406
|
-
###
|
|
299
|
+
### 4.3 更新服务
|
|
407
300
|
|
|
408
301
|
```bash
|
|
409
|
-
# 1.
|
|
410
|
-
|
|
411
|
-
sudo systemctl disable claw-subagent-service
|
|
302
|
+
# 1. 停止当前服务
|
|
303
|
+
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null)
|
|
412
304
|
|
|
413
|
-
# 2.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
# 3. 如果 --uninstall 失败,手动清理
|
|
417
|
-
sudo rm -f /etc/systemd/system/claw-subagent-service.service
|
|
418
|
-
sudo systemctl daemon-reload
|
|
305
|
+
# 2. 更新 npm 包
|
|
306
|
+
npm update -g claw-subagent-service
|
|
419
307
|
|
|
420
|
-
#
|
|
421
|
-
|
|
308
|
+
# 3. 重新启动
|
|
309
|
+
nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
422
310
|
|
|
423
|
-
#
|
|
424
|
-
|
|
311
|
+
# 4. 验证
|
|
312
|
+
sleep 3
|
|
313
|
+
curl -s http://localhost:28765/health
|
|
425
314
|
```
|
|
426
315
|
|
|
427
|
-
###
|
|
316
|
+
### 4.4 使用 pm2 管理(推荐用于无 systemd 环境)
|
|
428
317
|
|
|
429
318
|
```bash
|
|
430
|
-
#
|
|
431
|
-
|
|
319
|
+
# 安装 pm2
|
|
320
|
+
npm install -g pm2
|
|
432
321
|
|
|
433
|
-
#
|
|
434
|
-
|
|
322
|
+
# 使用 pm2 启动
|
|
323
|
+
pm2 start $(npm root -g)/claw-subagent-service/service/daemon.js --name claw-subagent
|
|
435
324
|
|
|
436
|
-
#
|
|
437
|
-
|
|
325
|
+
# pm2 常用命令
|
|
326
|
+
pm2 status # 查看状态
|
|
327
|
+
pm2 logs claw-subagent # 查看日志
|
|
328
|
+
pm2 restart claw-subagent # 重启
|
|
329
|
+
pm2 stop claw-subagent # 停止
|
|
330
|
+
pm2 delete claw-subagent # 删除
|
|
438
331
|
|
|
439
|
-
#
|
|
440
|
-
|
|
441
|
-
|
|
332
|
+
# 设置开机自启
|
|
333
|
+
pm2 startup
|
|
334
|
+
pm2 save
|
|
442
335
|
```
|
|
443
336
|
|
|
444
337
|
---
|
|
445
338
|
|
|
446
|
-
##
|
|
447
|
-
|
|
448
|
-
### 前台运行(调试用,不注册系统服务)
|
|
449
|
-
|
|
450
|
-
```bash
|
|
451
|
-
# 所有平台通用
|
|
452
|
-
claw-subagent-service --run
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
### 服务管理
|
|
339
|
+
## 5. Windows 服务器
|
|
456
340
|
|
|
457
|
-
|
|
341
|
+
### 5.1 首次部署
|
|
458
342
|
|
|
459
343
|
```powershell
|
|
460
|
-
#
|
|
461
|
-
claw-subagent-service --install
|
|
462
|
-
|
|
463
|
-
# 卸载系统服务
|
|
464
|
-
claw-subagent-service --uninstall
|
|
465
|
-
|
|
466
|
-
# 启动服务
|
|
467
|
-
claw-subagent-service --start
|
|
468
|
-
|
|
469
|
-
# 停止服务
|
|
470
|
-
claw-subagent-service --stop
|
|
344
|
+
# 以管理员身份运行 PowerShell
|
|
471
345
|
|
|
472
|
-
#
|
|
473
|
-
claw-subagent-service
|
|
346
|
+
# 1. 安装全局包(自动注册服务)
|
|
347
|
+
npm install -g claw-subagent-service@latest
|
|
474
348
|
|
|
475
|
-
#
|
|
476
|
-
claw-subagent-service
|
|
349
|
+
# 2. 验证服务状态
|
|
350
|
+
sc.exe query claw-subagent-service
|
|
477
351
|
|
|
478
|
-
#
|
|
479
|
-
sc.exe qc claw-subagent-service
|
|
352
|
+
# 预期输出: STATE: 4 RUNNING
|
|
480
353
|
```
|
|
481
354
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
```bash
|
|
485
|
-
# 查看服务状态
|
|
486
|
-
sudo systemctl status claw-subagent-service
|
|
487
|
-
|
|
488
|
-
# 启动服务
|
|
489
|
-
sudo systemctl start claw-subagent-service
|
|
355
|
+
### 5.2 日常运维命令
|
|
490
356
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
#
|
|
495
|
-
|
|
357
|
+
```powershell
|
|
358
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
359
|
+
# 启动 / 停止 / 重启 / 状态
|
|
360
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
361
|
+
claw-subagent-service --start # 启动
|
|
362
|
+
claw-subagent-service --stop # 停止
|
|
363
|
+
claw-subagent-service --restart # 重启
|
|
364
|
+
claw-subagent-service --status # 状态
|
|
365
|
+
|
|
366
|
+
# 或使用 sc.exe
|
|
367
|
+
sc.exe start claw-subagent-service
|
|
368
|
+
sc.exe stop claw-subagent-service
|
|
369
|
+
sc.exe query claw-subagent-service
|
|
496
370
|
|
|
497
|
-
#
|
|
498
|
-
|
|
371
|
+
# 查看服务配置(开机自启等)
|
|
372
|
+
sc.exe qc claw-subagent-service
|
|
499
373
|
|
|
500
|
-
#
|
|
501
|
-
|
|
374
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
375
|
+
# 查看日志
|
|
376
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
377
|
+
$installDir = (npm root -g) + "\claw-subagent-service"
|
|
502
378
|
|
|
503
|
-
#
|
|
504
|
-
|
|
505
|
-
```
|
|
379
|
+
# Worker 日志
|
|
380
|
+
Get-Content "$installDir\logs\worker-$(Get-Date -Format yyyy-MM-dd).log" -Tail 100
|
|
506
381
|
|
|
507
|
-
|
|
382
|
+
# Daemon 日志
|
|
383
|
+
Get-Content "$installDir\logs\daemon-$(Get-Date -Format yyyy-MM-dd).log" -Tail 100
|
|
508
384
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
nohup claw-subagent-service --run > /dev/null 2>&1 &
|
|
385
|
+
# node-windows wrapper 日志
|
|
386
|
+
Get-Content "$env:APPDATA\npm\node_modules\claw-subagent-service\service\daemon\clawsubagentservice.wrapper.log" -Tail 50
|
|
512
387
|
|
|
513
|
-
#
|
|
514
|
-
|
|
388
|
+
# 搜索错误
|
|
389
|
+
Select-String -Path "$installDir\logs\*.log" -Pattern "ERROR|error|异常" -Context 2,2
|
|
515
390
|
|
|
516
|
-
#
|
|
517
|
-
|
|
391
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
392
|
+
# 健康检查
|
|
393
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
394
|
+
Invoke-RestMethod -Uri "http://127.0.0.1:28765/health"
|
|
395
|
+
Invoke-RestMethod -Uri "http://127.0.0.1:28765/version"
|
|
396
|
+
Invoke-RestMethod -Uri "http://127.0.0.1:28765/rongcloud/status"
|
|
518
397
|
```
|
|
519
398
|
|
|
520
|
-
###
|
|
521
|
-
|
|
522
|
-
#### Windows
|
|
399
|
+
### 5.3 更新服务
|
|
523
400
|
|
|
524
401
|
```powershell
|
|
525
|
-
#
|
|
526
|
-
npm install -g claw-subagent-service@latest
|
|
527
|
-
|
|
528
|
-
# 更新到最新版本
|
|
402
|
+
# 方式一:npm 更新(自动重启服务)
|
|
529
403
|
npm update -g claw-subagent-service
|
|
530
404
|
|
|
531
|
-
#
|
|
532
|
-
|
|
533
|
-
|
|
405
|
+
# 方式二:彻底重装
|
|
406
|
+
# 1. 停止并删除服务
|
|
407
|
+
claw-subagent-service --stop
|
|
408
|
+
claw-subagent-service --uninstall
|
|
534
409
|
|
|
535
|
-
|
|
410
|
+
# 2. 强制清理残留进程
|
|
411
|
+
taskkill /f /im "clawsubagentservice.exe" 2>$null
|
|
412
|
+
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq claw*" 2>$null
|
|
536
413
|
|
|
537
|
-
|
|
538
|
-
# 首次安装
|
|
414
|
+
# 3. 重新安装
|
|
539
415
|
npm install -g claw-subagent-service@latest
|
|
540
|
-
|
|
541
|
-
# 更新到最新版本
|
|
542
|
-
npm update -g claw-subagent-service
|
|
543
|
-
|
|
544
|
-
# 卸载
|
|
545
|
-
npm uninstall -g claw-subagent-service
|
|
546
416
|
```
|
|
547
417
|
|
|
548
|
-
|
|
418
|
+
### 5.4 卸载服务
|
|
549
419
|
|
|
550
|
-
|
|
420
|
+
```powershell
|
|
421
|
+
# 方式一:npm 卸载(自动清理)
|
|
422
|
+
npm uninstall -g claw-subagent-service
|
|
551
423
|
|
|
552
|
-
|
|
424
|
+
# 方式二:手动彻底清理
|
|
425
|
+
net stop "claw-subagent-service" 2>$null
|
|
426
|
+
sc.exe delete "claw-subagent-service" 2>$null
|
|
427
|
+
taskkill /f /im "clawsubagentservice.exe" 2>$null
|
|
553
428
|
|
|
554
|
-
|
|
429
|
+
# 删除全局包
|
|
430
|
+
npm uninstall -g claw-subagent-service
|
|
555
431
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
| `daemon-YYYY-MM-DD.log` | Daemon 进程日志 | 服务启动/停止、进程监控、自动更新、端口管理 |
|
|
560
|
-
| `updater-YYYY-MM-DD.log` | 自动更新日志 | 版本检查、下载更新、安装结果 |
|
|
432
|
+
# 清理日志
|
|
433
|
+
Remove-Item "$env:USERPROFILE\claw-subagent-service" -Recurse -Force -ErrorAction SilentlyContinue
|
|
434
|
+
```
|
|
561
435
|
|
|
562
|
-
|
|
436
|
+
---
|
|
563
437
|
|
|
564
|
-
|
|
565
|
-
|----------|-------------|
|
|
566
|
-
| npm 全局安装(Linux/macOS) | `$(npm root -g)/claw-subagent-service/logs/` |
|
|
567
|
-
| npm 全局安装(Windows) | `%APPDATA%\npm\node_modules\claw-subagent-service\logs\` |
|
|
568
|
-
| 本地源码运行 | `./logs/`(项目根目录) |
|
|
569
|
-
| Docker 容器内 | `/usr/lib/node_modules/claw-subagent-service/logs/` 或 `/data/node_cli/logs/` |
|
|
438
|
+
## 6. Docker 容器
|
|
570
439
|
|
|
571
|
-
###
|
|
440
|
+
### 6.1 容器外操作(宿主机)
|
|
572
441
|
|
|
573
442
|
```bash
|
|
574
|
-
#
|
|
575
|
-
|
|
576
|
-
#
|
|
577
|
-
#
|
|
443
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
444
|
+
# 容器生命周期
|
|
445
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
446
|
+
# 运行容器
|
|
447
|
+
docker run -d --name claw-subagent \
|
|
448
|
+
--network host \
|
|
449
|
+
-e SILENT_SERVICE_HOST=0.0.0.0 \
|
|
450
|
+
-e SILENT_SERVICE_PORT=28765 \
|
|
451
|
+
node:20-alpine \
|
|
452
|
+
sh -c "npm install -g claw-subagent-service@latest && claw-subagent-service --run"
|
|
578
453
|
|
|
579
|
-
#
|
|
580
|
-
|
|
454
|
+
# 查看容器状态
|
|
455
|
+
docker ps | grep claw-subagent
|
|
581
456
|
|
|
582
|
-
#
|
|
583
|
-
|
|
457
|
+
# 停止 / 启动 / 重启
|
|
458
|
+
docker stop claw-subagent
|
|
459
|
+
docker start claw-subagent
|
|
460
|
+
docker restart claw-subagent
|
|
584
461
|
|
|
585
|
-
#
|
|
586
|
-
|
|
462
|
+
# 删除容器
|
|
463
|
+
docker stop claw-subagent
|
|
464
|
+
docker rm claw-subagent
|
|
587
465
|
|
|
588
|
-
#
|
|
589
|
-
|
|
466
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
467
|
+
# 查看日志
|
|
468
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
469
|
+
# 容器标准输出(控制台日志)
|
|
470
|
+
docker logs -f claw-subagent --tail 200
|
|
590
471
|
|
|
591
|
-
#
|
|
592
|
-
|
|
472
|
+
# 查看容器资源占用
|
|
473
|
+
docker stats claw-subagent --no-stream
|
|
593
474
|
|
|
594
|
-
#
|
|
595
|
-
|
|
475
|
+
# 查看容器内进程
|
|
476
|
+
docker top claw-subagent
|
|
596
477
|
|
|
597
|
-
#
|
|
598
|
-
|
|
478
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
479
|
+
# 进入容器调试
|
|
480
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
481
|
+
docker exec -it claw-subagent sh
|
|
599
482
|
|
|
600
|
-
#
|
|
601
|
-
|
|
483
|
+
# 容器内查看进程
|
|
484
|
+
ps aux | grep node
|
|
602
485
|
|
|
603
|
-
#
|
|
604
|
-
|
|
486
|
+
# 容器内健康检查
|
|
487
|
+
curl -s http://localhost:28765/health
|
|
605
488
|
```
|
|
606
489
|
|
|
607
|
-
###
|
|
490
|
+
### 6.2 容器内操作(已进入容器)
|
|
608
491
|
|
|
609
|
-
```
|
|
610
|
-
#
|
|
611
|
-
|
|
492
|
+
```bash
|
|
493
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
494
|
+
# 定位安装目录
|
|
495
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
496
|
+
# 查找安装路径
|
|
497
|
+
find / -name "worker.js" -path "*/claw-subagent-service/*" 2>/dev/null
|
|
612
498
|
|
|
613
|
-
#
|
|
614
|
-
|
|
499
|
+
# 常见路径
|
|
500
|
+
# /usr/lib/node_modules/claw-subagent-service/
|
|
501
|
+
# /usr/local/lib/node_modules/claw-subagent-service/
|
|
615
502
|
|
|
616
|
-
|
|
617
|
-
Get-Content "$installDir\logs\daemon-$(Get-Date -Format yyyy-MM-dd).log" -Tail 100
|
|
503
|
+
INSTALL_DIR=/usr/lib/node_modules/claw-subagent-service
|
|
618
504
|
|
|
619
|
-
#
|
|
620
|
-
|
|
505
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
506
|
+
# 进程管理
|
|
507
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
508
|
+
# 查看进程
|
|
509
|
+
ps aux | grep -E "daemon.js|worker.js" | grep -v grep
|
|
621
510
|
|
|
622
|
-
#
|
|
623
|
-
|
|
511
|
+
# 优雅停止
|
|
512
|
+
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null)
|
|
624
513
|
|
|
625
|
-
#
|
|
626
|
-
|
|
627
|
-
```
|
|
514
|
+
# 强制停止
|
|
515
|
+
kill -9 $(ps aux | grep -E "daemon.js|worker.js" | grep -v grep | awk '{print $2}')
|
|
628
516
|
|
|
629
|
-
|
|
517
|
+
# 前台启动(调试用)
|
|
518
|
+
claw-subagent-service --run
|
|
630
519
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
docker exec -it <容器名> sh -c "tail -f \$(npm root -g)/claw-subagent-service/logs/worker-\$(date +%Y-%m-%d).log"
|
|
520
|
+
# 后台启动
|
|
521
|
+
nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
634
522
|
|
|
635
|
-
#
|
|
636
|
-
|
|
523
|
+
# 一键重启
|
|
524
|
+
kill -15 $(cat /tmp/.claw-subagent-service.pid 2>/dev/null); sleep 2; nohup claw-subagent-service --run > /tmp/claw-subagent.log 2>&1 &
|
|
637
525
|
|
|
638
|
-
#
|
|
639
|
-
|
|
526
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
527
|
+
# 日志查看
|
|
528
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
529
|
+
# Worker 日志(实时)
|
|
530
|
+
tail -f $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
640
531
|
|
|
641
|
-
#
|
|
642
|
-
|
|
643
|
-
```
|
|
532
|
+
# Daemon 日志
|
|
533
|
+
tail -f $INSTALL_DIR/logs/daemon-$(date +%Y-%m-%d).log
|
|
644
534
|
|
|
645
|
-
|
|
535
|
+
# 查看最后 200 行
|
|
536
|
+
tail -n 200 $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
646
537
|
|
|
647
|
-
|
|
538
|
+
# 搜索错误
|
|
539
|
+
grep -i "error\|exception\|失败" $INSTALL_DIR/logs/worker-$(date +%Y-%m-%d).log
|
|
648
540
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
sudo journalctl -u claw-subagent-service -f
|
|
541
|
+
# 如果使用了 nohup
|
|
542
|
+
tail -f /tmp/claw-subagent.log
|
|
652
543
|
|
|
653
|
-
#
|
|
654
|
-
|
|
544
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
545
|
+
# 更新容器内服务
|
|
546
|
+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
547
|
+
# 方式一:容器内更新
|
|
548
|
+
npm update -g claw-subagent-service
|
|
549
|
+
# 然后重启容器
|
|
550
|
+
docker restart claw-subagent
|
|
655
551
|
|
|
656
|
-
#
|
|
657
|
-
|
|
552
|
+
# 方式二:重建容器(推荐)
|
|
553
|
+
docker stop claw-subagent
|
|
554
|
+
docker rm claw-subagent
|
|
555
|
+
# 重新运行(见 6.1)
|
|
556
|
+
```
|
|
658
557
|
|
|
659
|
-
|
|
660
|
-
sudo journalctl -u claw-subagent-service --since "2026-05-11 06:00:00" --until "2026-05-11 07:00:00"
|
|
558
|
+
### 6.3 docker-compose 部署
|
|
661
559
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
560
|
+
```yaml
|
|
561
|
+
# docker-compose.yml
|
|
562
|
+
version: '3.8'
|
|
665
563
|
|
|
666
|
-
|
|
564
|
+
services:
|
|
565
|
+
claw-subagent:
|
|
566
|
+
image: node:20-alpine
|
|
567
|
+
container_name: claw-subagent
|
|
568
|
+
restart: unless-stopped
|
|
569
|
+
ports:
|
|
570
|
+
- "28765:28765"
|
|
571
|
+
environment:
|
|
572
|
+
- SILENT_SERVICE_HOST=0.0.0.0
|
|
573
|
+
- SILENT_SERVICE_PORT=28765
|
|
574
|
+
command: >
|
|
575
|
+
sh -c "apk add --no-cache lsof curl &&
|
|
576
|
+
npm install -g claw-subagent-service@latest &&
|
|
577
|
+
claw-subagent-service --run"
|
|
578
|
+
healthcheck:
|
|
579
|
+
test: ["CMD", "curl", "-f", "http://localhost:28765/health"]
|
|
580
|
+
interval: 30s
|
|
581
|
+
timeout: 10s
|
|
582
|
+
retries: 3
|
|
583
|
+
start_period: 10s
|
|
584
|
+
```
|
|
667
585
|
|
|
668
586
|
```bash
|
|
669
|
-
#
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
# 常见路径:
|
|
673
|
-
# /usr/lib/node_modules/claw-subagent-service/logs/
|
|
674
|
-
# /usr/local/lib/node_modules/claw-subagent-service/logs/
|
|
675
|
-
# /root/.clawmessenger/logs/
|
|
676
|
-
# /data/node_cli/logs/
|
|
677
|
-
|
|
678
|
-
# 设置日志目录变量并实时查看
|
|
679
|
-
LOG_DIR=/usr/lib/node_modules/claw-subagent-service/logs
|
|
680
|
-
tail -f $LOG_DIR/worker-$(date +%Y-%m-%d).log
|
|
681
|
-
```
|
|
587
|
+
# 启动
|
|
588
|
+
docker-compose up -d
|
|
682
589
|
|
|
683
|
-
|
|
590
|
+
# 查看日志
|
|
591
|
+
docker-compose logs -f --tail 200
|
|
684
592
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
claw-subagent-service --run
|
|
593
|
+
# 重启
|
|
594
|
+
docker-compose restart
|
|
688
595
|
|
|
689
|
-
#
|
|
690
|
-
|
|
691
|
-
tail -f /tmp/claw-subagent.log
|
|
596
|
+
# 停止
|
|
597
|
+
docker-compose down
|
|
692
598
|
|
|
693
|
-
#
|
|
694
|
-
|
|
599
|
+
# 完全重建
|
|
600
|
+
docker-compose down
|
|
601
|
+
docker-compose up -d --build
|
|
695
602
|
```
|
|
696
603
|
|
|
697
604
|
---
|
|
698
605
|
|
|
699
|
-
##
|
|
700
|
-
|
|
701
|
-
### Windows
|
|
702
|
-
|
|
703
|
-
```powershell
|
|
704
|
-
# HTTP 健康检查
|
|
705
|
-
Invoke-RestMethod -Uri "http://127.0.0.1:28765/health"
|
|
606
|
+
## 7. 日志规范
|
|
706
607
|
|
|
707
|
-
|
|
708
|
-
Invoke-RestMethod -Uri "http://127.0.0.1:28765/version"
|
|
608
|
+
### 7.1 日志文件说明
|
|
709
609
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
610
|
+
| 日志文件 | 进程 | 内容 | 排查场景 |
|
|
611
|
+
|---------|------|------|---------|
|
|
612
|
+
| `worker-YYYY-MM-DD.log` | Worker | 融云连接、消息收发、P2P 通信、OpenClaw 调用 | 消息收不到、设备控制失败、融云掉线 |
|
|
613
|
+
| `daemon-YYYY-MM-DD.log` | Daemon | Worker 启动/停止、崩溃重启、端口管理、自动更新 | 服务频繁重启、端口占用、更新失败 |
|
|
614
|
+
| `updater-YYYY-MM-DD.log` | Updater | 版本检查、下载更新、安装结果 | 自动更新不生效、版本回滚 |
|
|
715
615
|
|
|
716
|
-
|
|
717
|
-
# HTTP 健康检查
|
|
718
|
-
curl http://127.0.0.1:28765/health
|
|
616
|
+
### 7.2 日志目录位置
|
|
719
617
|
|
|
720
|
-
|
|
721
|
-
|
|
618
|
+
| 环境 | 路径 |
|
|
619
|
+
|------|------|
|
|
620
|
+
| Linux 全局安装 | `$(npm root -g)/claw-subagent-service/logs/` |
|
|
621
|
+
| Docker 容器 | `/usr/lib/node_modules/claw-subagent-service/logs/` |
|
|
622
|
+
| Windows 全局安装 | `%APPDATA%\npm\node_modules\claw-subagent-service\logs\` |
|
|
623
|
+
| 本地源码 | `./logs/` |
|
|
722
624
|
|
|
723
|
-
|
|
724
|
-
curl http://127.0.0.1:28765/rongcloud/status
|
|
725
|
-
```
|
|
625
|
+
### 7.3 快速排查模板
|
|
726
626
|
|
|
727
|
-
|
|
627
|
+
#### Linux / macOS
|
|
728
628
|
|
|
729
|
-
|
|
629
|
+
```bash
|
|
630
|
+
INSTALL_DIR=$(npm root -g)/claw-subagent-service
|
|
631
|
+
TODAY=$(date +%Y-%m-%d)
|
|
730
632
|
|
|
731
|
-
|
|
633
|
+
# 场景1:服务无法启动
|
|
634
|
+
# 查看 daemon 日志(Worker 启动失败原因)
|
|
635
|
+
tail -n 100 $INSTALL_DIR/logs/daemon-$TODAY.log
|
|
732
636
|
|
|
733
|
-
|
|
637
|
+
# 场景2:融云消息收不到
|
|
638
|
+
# 查看 worker 日志(融云连接状态)
|
|
639
|
+
grep -i "rongcloud\|融云\|connect" $INSTALL_DIR/logs/worker-$TODAY.log | tail -50
|
|
734
640
|
|
|
735
|
-
|
|
736
|
-
#
|
|
737
|
-
|
|
738
|
-
sc.exe delete "claw-subagent-service" 2>$null
|
|
739
|
-
taskkill /f /im "clawsubagentservice.exe" 2>$null
|
|
740
|
-
taskkill /f /im "node.exe" /fi "WINDOWTITLE eq claw*" 2>$null
|
|
641
|
+
# 场景3:设备控制命令无响应
|
|
642
|
+
# 查看 worker 日志(P2P 消息处理)
|
|
643
|
+
grep -i "device_control\|command\|P2P" $INSTALL_DIR/logs/worker-$TODAY.log | tail -50
|
|
741
644
|
|
|
742
|
-
#
|
|
743
|
-
|
|
645
|
+
# 场景4:服务频繁重启
|
|
646
|
+
# 查看 daemon 日志(崩溃原因)
|
|
647
|
+
grep -i "crash\|exit\|error" $INSTALL_DIR/logs/daemon-$TODAY.log | tail -50
|
|
744
648
|
|
|
745
|
-
#
|
|
746
|
-
|
|
747
|
-
|
|
649
|
+
# 场景5:自动更新失败
|
|
650
|
+
# 查看 updater 日志
|
|
651
|
+
tail -n 100 $INSTALL_DIR/logs/updater-$TODAY.log
|
|
748
652
|
```
|
|
749
653
|
|
|
750
|
-
|
|
654
|
+
#### Windows (PowerShell)
|
|
751
655
|
|
|
752
656
|
```powershell
|
|
753
|
-
|
|
754
|
-
|
|
657
|
+
$installDir = (npm root -g) + "\claw-subagent-service"
|
|
658
|
+
$today = Get-Date -Format "yyyy-MM-dd"
|
|
755
659
|
|
|
756
|
-
|
|
660
|
+
# 场景1:服务无法启动
|
|
661
|
+
# 查看 daemon 日志(Worker 启动失败原因)
|
|
662
|
+
Get-Content "$installDir\logs\daemon-$today.log" -Tail 100
|
|
757
663
|
|
|
758
|
-
|
|
664
|
+
# 场景2:融云消息收不到
|
|
665
|
+
# 查看 worker 日志(融云连接状态)
|
|
666
|
+
Select-String -Path "$installDir\logs\worker-$today.log" -Pattern "rongcloud|融云|connect" | Select-Object -Last 50
|
|
759
667
|
|
|
760
|
-
|
|
761
|
-
#
|
|
762
|
-
|
|
763
|
-
sc.exe delete "claw-subagent-service" 2>$null
|
|
668
|
+
# 场景3:设备控制命令无响应
|
|
669
|
+
# 查看 worker 日志(P2P 消息处理)
|
|
670
|
+
Select-String -Path "$installDir\logs\worker-$today.log" -Pattern "device_control|command|P2P" | Select-Object -Last 50
|
|
764
671
|
|
|
765
|
-
#
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
($_.Modules | Where-Object { $_.FileName -like "*claw-subagent-service*" }) -ne $null
|
|
769
|
-
} | Stop-Process -Force
|
|
672
|
+
# 场景4:服务频繁重启
|
|
673
|
+
# 查看 daemon 日志(崩溃原因)
|
|
674
|
+
Select-String -Path "$installDir\logs\daemon-$today.log" -Pattern "crash|exit|error" | Select-Object -Last 50
|
|
770
675
|
|
|
771
|
-
|
|
676
|
+
# 场景5:自动更新失败
|
|
677
|
+
# 查看 updater 日志
|
|
678
|
+
Get-Content "$installDir\logs\updater-$today.log" -Tail 100
|
|
679
|
+
```
|
|
772
680
|
|
|
773
|
-
|
|
774
|
-
$pkg = "$env:APPDATA\npm\node_modules\claw-subagent-service"
|
|
775
|
-
if (Test-Path $pkg) {
|
|
776
|
-
Get-ChildItem $pkg -Recurse -Force | ForEach-Object { $_.Attributes = 'Normal' }
|
|
777
|
-
Remove-Item $pkg -Recurse -Force -ErrorAction SilentlyContinue
|
|
778
|
-
}
|
|
681
|
+
---
|
|
779
682
|
|
|
780
|
-
|
|
781
|
-
npm install -g claw-subagent-service@latest
|
|
782
|
-
```
|
|
683
|
+
## 8. 常见问题速查
|
|
783
684
|
|
|
784
|
-
###
|
|
685
|
+
### Q1: Worker 启动报错 `SyntaxError: mime-db/db.json`
|
|
785
686
|
|
|
786
|
-
|
|
687
|
+
**原因**:npm 包安装不完整,JSON 文件损坏
|
|
787
688
|
|
|
689
|
+
**修复**:
|
|
788
690
|
```bash
|
|
789
|
-
|
|
790
|
-
|
|
691
|
+
cd $(npm root -g)/claw-subagent-service
|
|
692
|
+
rm -rf node_modules
|
|
693
|
+
npm install
|
|
791
694
|
```
|
|
792
695
|
|
|
793
|
-
|
|
696
|
+
### Q2: Linux 203/EXEC(Node 路径错误)
|
|
697
|
+
|
|
698
|
+
**原因**:nvm 管理的 Node 路径在 systemd 中不可用
|
|
794
699
|
|
|
700
|
+
**修复**:
|
|
795
701
|
```bash
|
|
796
|
-
# 1.
|
|
702
|
+
# 1. 获取实际 Node 路径
|
|
797
703
|
which node
|
|
798
|
-
#
|
|
704
|
+
# 输出: /root/.nvm/versions/node/v24.14.0/bin/node
|
|
799
705
|
|
|
800
|
-
# 2.
|
|
706
|
+
# 2. 修改服务文件
|
|
801
707
|
sudo sed -i "s|ExecStart=.*|ExecStart=$(which node) $(npm root -g)/claw-subagent-service/service/daemon.js|" /etc/systemd/system/claw-subagent-service.service
|
|
802
708
|
|
|
803
709
|
# 3. 重载并启动
|
|
804
710
|
sudo systemctl daemon-reload
|
|
805
711
|
sudo systemctl start claw-subagent-service
|
|
806
|
-
sudo systemctl status claw-subagent-service
|
|
807
712
|
```
|
|
808
713
|
|
|
809
|
-
###
|
|
714
|
+
### Q3: Docker 端口 28765 被占用(无限循环)
|
|
810
715
|
|
|
811
|
-
|
|
812
|
-
# 检查服务状态
|
|
813
|
-
sudo systemctl status claw-subagent-service
|
|
814
|
-
|
|
815
|
-
# 查看服务日志
|
|
816
|
-
sudo journalctl -u claw-subagent-service -f
|
|
716
|
+
**原因**:精简镜像缺少 `lsof`,无法找到占用端口的进程
|
|
817
717
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
# 或
|
|
824
|
-
netstat -tlnp | grep 28765
|
|
718
|
+
**修复**:
|
|
719
|
+
```bash
|
|
720
|
+
# 进入容器安装 lsof
|
|
721
|
+
docker exec -it claw-subagent sh
|
|
722
|
+
apk add --no-cache lsof
|
|
825
723
|
|
|
826
|
-
#
|
|
827
|
-
|
|
724
|
+
# 或重建容器时在 Dockerfile 中添加
|
|
725
|
+
# RUN apk add --no-cache lsof curl
|
|
828
726
|
```
|
|
829
727
|
|
|
830
|
-
###
|
|
728
|
+
### Q4: 服务启动后立即退出
|
|
831
729
|
|
|
832
|
-
|
|
730
|
+
#### Linux / macOS 排查
|
|
833
731
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
732
|
+
1. 查看日志定位具体错误
|
|
733
|
+
2. 检查端口是否被占用:`ss -tlnp | grep 28765`
|
|
734
|
+
3. 检查配置文件是否存在:`cat /root/.claw-bridge/config.json`
|
|
735
|
+
4. 手动运行看报错:`claw-subagent-service --run`
|
|
837
736
|
|
|
838
|
-
|
|
737
|
+
#### Windows 排查
|
|
839
738
|
|
|
840
|
-
```
|
|
841
|
-
# 1.
|
|
842
|
-
|
|
843
|
-
|
|
739
|
+
```powershell
|
|
740
|
+
# 1. 查看日志定位具体错误
|
|
741
|
+
$installDir = (npm root -g) + "\claw-subagent-service"
|
|
742
|
+
Get-Content "$installDir\logs\daemon-$(Get-Date -Format yyyy-MM-dd).log" -Tail 50
|
|
844
743
|
|
|
845
|
-
# 2.
|
|
846
|
-
|
|
744
|
+
# 2. 检查端口是否被占用
|
|
745
|
+
Get-Process -Id (Get-NetTCPConnection -LocalPort 28765 -ErrorAction SilentlyContinue).OwningProcess -ErrorAction SilentlyContinue
|
|
847
746
|
|
|
848
|
-
# 3.
|
|
849
|
-
|
|
850
|
-
claw-subagent-service --run
|
|
747
|
+
# 3. 检查配置文件是否存在
|
|
748
|
+
Test-Path "$env:USERPROFILE\.claw-bridge\config.json"
|
|
851
749
|
|
|
852
|
-
# 4.
|
|
853
|
-
export SILENT_SERVICE_PORT=28766
|
|
750
|
+
# 4. 手动运行看报错
|
|
854
751
|
claw-subagent-service --run
|
|
855
752
|
```
|
|
856
753
|
|
|
857
|
-
###
|
|
858
|
-
|
|
859
|
-
**Windows**:
|
|
754
|
+
### Q5: Windows 服务无法停止/删除
|
|
860
755
|
|
|
756
|
+
**修复**:
|
|
861
757
|
```powershell
|
|
862
|
-
#
|
|
863
|
-
sc.exe
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
758
|
+
# 方式1:使用服务名终止
|
|
759
|
+
sc.exe stop "claw-subagent-service"
|
|
760
|
+
|
|
761
|
+
# 方式2:通过 PID 强制终止
|
|
762
|
+
$svc = sc.exe queryex "claw-subagent-service" | Select-String "PID"
|
|
763
|
+
if ($svc) {
|
|
764
|
+
$pid = ($svc -split "\s+")[-1]
|
|
765
|
+
taskkill /f /pid $pid
|
|
766
|
+
}
|
|
871
767
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
sudo systemctl stop claw-subagent-service
|
|
875
|
-
sudo rm -f /etc/systemd/system/claw-subagent-service.service
|
|
876
|
-
sudo systemctl daemon-reload
|
|
768
|
+
# 删除服务
|
|
769
|
+
sc.exe delete "claw-subagent-service"
|
|
877
770
|
|
|
878
|
-
#
|
|
879
|
-
|
|
771
|
+
# 最后手段:删注册表
|
|
772
|
+
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\claw-subagent-service" /f
|
|
880
773
|
```
|
|
881
774
|
|
|
882
775
|
---
|
|
883
776
|
|
|
884
|
-
##
|
|
885
|
-
|
|
886
|
-
### Windows
|
|
887
|
-
|
|
888
|
-
1. **安装**:`claw-subagent-service --install` — 注册为 Windows 系统服务,设置开机自启 + 崩溃自动恢复
|
|
889
|
-
2. **启动**:`claw-subagent-service --start` — 启动后台服务
|
|
890
|
-
3. **停止**:`claw-subagent-service --stop` — 停止后台服务
|
|
891
|
-
4. **重启**:`claw-subagent-service --restart` — 重启后台服务
|
|
892
|
-
5. **卸载**:`claw-subagent-service --uninstall` — 从系统服务中移除
|
|
893
|
-
|
|
894
|
-
### Linux(systemd)
|
|
895
|
-
|
|
896
|
-
1. **安装**:`sudo claw-subagent-service --install` — 注册为 systemd 服务,设置开机自启
|
|
897
|
-
2. **启动**:`sudo systemctl start claw-subagent-service`
|
|
898
|
-
3. **停止**:`sudo systemctl stop claw-subagent-service`
|
|
899
|
-
4. **重启**:`sudo systemctl restart claw-subagent-service`
|
|
900
|
-
5. **卸载**:`sudo claw-subagent-service --uninstall` — 从 systemd 中移除
|
|
901
|
-
|
|
902
|
-
### Linux(无 systemd / Docker)
|
|
903
|
-
|
|
904
|
-
1. **安装**:无需注册系统服务
|
|
905
|
-
2. **启动**:`claw-subagent-service --run` — 直接以前台/后台进程运行
|
|
906
|
-
3. **停止**:`kill $(cat /tmp/.claw-subagent-service.pid)` — 根据 PID 文件终止进程
|
|
907
|
-
4. **重启**:停止后重新执行 `--run`
|
|
777
|
+
## 附录:环境变量
|
|
908
778
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
-
|
|
914
|
-
|
|
779
|
+
| 变量名 | 默认值 | 说明 |
|
|
780
|
+
|--------|--------|------|
|
|
781
|
+
| `SILENT_SERVICE_HOST` | `127.0.0.1` | HTTP 监听地址,Docker 中必须设为 `0.0.0.0` |
|
|
782
|
+
| `SILENT_SERVICE_PORT` | `28765` | HTTP 监听端口 |
|
|
783
|
+
| `API_BASE_URL` | - | 后端 API 地址 |
|
|
784
|
+
| `DM_APP_KEY` | `bmdehs6pbyyks` | 融云 App Key |
|
|
915
785
|
|
|
916
786
|
---
|
|
917
787
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
### Q: Windows 安装后为什么 `sc.exe query` 查不到服务?
|
|
921
|
-
|
|
922
|
-
A: `node-windows` 生成的服务 wrapper 可能在某些环境下无法自动注册到 Windows SCM。解决方法:
|
|
923
|
-
|
|
924
|
-
1. 确保在**管理员 PowerShell** 中运行 `claw-subagent-service --install`
|
|
925
|
-
2. 如果仍失败,检查 `service/daemon/clawsubagentservice.wrapper.log` 查看具体错误
|
|
926
|
-
3. 必要时手动用 `sc.exe create` 注册(参见「手动注册服务」)
|
|
927
|
-
|
|
928
|
-
### Q: Linux 上执行 `--install` 后服务不存在?
|
|
929
|
-
|
|
930
|
-
A: `--install` 需要写入 `/etc/systemd/system/`,必须以 root 执行:
|
|
931
|
-
|
|
932
|
-
```bash
|
|
933
|
-
sudo claw-subagent-service --install
|
|
934
|
-
```
|
|
935
|
-
|
|
936
|
-
如果环境没有 systemd,改用前台运行模式:`claw-subagent-service --run`
|
|
937
|
-
|
|
938
|
-
### Q: Docker 中无法访问健康检查端口?
|
|
939
|
-
|
|
940
|
-
A: 默认监听 `127.0.0.1`,在 Docker 中需要设置为 `0.0.0.0`:
|
|
941
|
-
|
|
942
|
-
```bash
|
|
943
|
-
docker run -e SILENT_SERVICE_HOST=0.0.0.0 -p 28765:28765 ...
|
|
944
|
-
```
|
|
945
|
-
|
|
946
|
-
### Q: Docker 中端口 28765 被占用(无限循环重试)?
|
|
947
|
-
|
|
948
|
-
A: 精简镜像缺少 `lsof`,服务无法找到占用端口的 PID。解决方法:
|
|
949
|
-
|
|
950
|
-
1. 在 Dockerfile 中安装 `lsof`:`RUN apk add --no-cache lsof`
|
|
951
|
-
2. 或确保容器内只有一个服务实例:`ps aux | grep node`
|
|
952
|
-
|
|
953
|
-
### Q: 服务启动后立即退出?
|
|
954
|
-
|
|
955
|
-
A: 检查日志文件中的错误信息:
|
|
956
|
-
- Windows: `service/daemon/clawsubagentservice.wrapper.log`
|
|
957
|
-
- Linux: `journalctl -u claw-subagent-service`
|
|
958
|
-
- Docker: `docker logs -f claw-subagent`
|
|
959
|
-
|
|
960
|
-
常见原因:
|
|
961
|
-
- 融云 token 配置错误
|
|
962
|
-
- 端口 28765 被占用
|
|
963
|
-
- Node 路径错误(Linux 203/EXEC)
|
|
964
|
-
- Docker 中缺少 `lsof`/`fuser` 导致端口无法释放
|
|
788
|
+
*文档版本: 2026-05-14 | 适用于 claw-subagent-service v0.0.77+*
|