claw-subagent-service 0.0.140 → 0.0.142
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/command/linux/restart.sh
CHANGED
|
@@ -187,51 +187,70 @@ restart_docker() {
|
|
|
187
187
|
# 如果正在运行,先停止(包括进程存在但端口未监听的情况)
|
|
188
188
|
if [ -n "$pid" ] || check_port "$PORT"; then
|
|
189
189
|
log_info "正在停止 OpenClaw 服务..."
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
190
|
+
|
|
191
|
+
# 第一步:优雅停止所有 openclaw 进程
|
|
192
|
+
log_info "发送 SIGTERM 到所有 openclaw 进程..."
|
|
193
|
+
pkill -15 -f "openclaw" &>/dev/null || true
|
|
194
|
+
sleep 3
|
|
195
|
+
|
|
196
|
+
# 第二步:检查是否还有进程在运行
|
|
197
|
+
local remaining_pids=""
|
|
198
|
+
if command -v pgrep &>/dev/null; then
|
|
199
|
+
remaining_pids=$(pgrep -f "openclaw" | tr '\n' ' ')
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
if [ -n "$remaining_pids" ]; then
|
|
203
|
+
log_warn "进程仍在运行: $remaining_pids,发送 SIGKILL..."
|
|
204
|
+
pkill -9 -f "openclaw" &>/dev/null || true
|
|
205
|
+
sleep 3
|
|
200
206
|
fi
|
|
201
207
|
|
|
202
|
-
#
|
|
208
|
+
# 第三步:连续监控,确保所有进程都停止(防止看门狗重启)
|
|
209
|
+
log_info "进入连续监控模式,确保进程完全停止..."
|
|
203
210
|
local elapsed=0
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
current_pid=$(get_openclaw_pid)
|
|
207
|
-
if [ -z "$current_pid" ] && ! check_port "$PORT"; then
|
|
208
|
-
break
|
|
209
|
-
fi
|
|
211
|
+
local consecutive_empty=0
|
|
212
|
+
while [ $elapsed -lt 15 ]; do
|
|
210
213
|
sleep 1
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
local current_pid_after_wait
|
|
216
|
-
current_pid_after_wait=$(get_openclaw_pid)
|
|
217
|
-
if [ -n "$current_pid_after_wait" ] || check_port "$PORT"; then
|
|
218
|
-
log_warn "服务未在 10 秒内停止,正在强制停止..."
|
|
219
|
-
if [ -n "$current_pid_after_wait" ]; then
|
|
220
|
-
kill -9 "$current_pid_after_wait" &>/dev/null || true
|
|
221
|
-
fi
|
|
222
|
-
pkill -9 -f "openclaw" &>/dev/null || true
|
|
223
|
-
if command -v fuser &>/dev/null; then
|
|
224
|
-
fuser -k "${PORT}/tcp" &>/dev/null || true
|
|
214
|
+
|
|
215
|
+
local current_pids=""
|
|
216
|
+
if command -v pgrep &>/dev/null; then
|
|
217
|
+
current_pids=$(pgrep -f "openclaw" | tr '\n' ' ')
|
|
225
218
|
fi
|
|
226
|
-
sleep 2
|
|
227
219
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
220
|
+
if [ -z "$current_pids" ] && ! check_port "$PORT"; then
|
|
221
|
+
consecutive_empty=$((consecutive_empty + 1))
|
|
222
|
+
log_info "第 $elapsed 秒: 无进程且端口未监听(连续 $consecutive_empty 次)"
|
|
223
|
+
if [ $consecutive_empty -ge 3 ]; then
|
|
224
|
+
log_info "服务已完全停止"
|
|
225
|
+
break
|
|
226
|
+
fi
|
|
227
|
+
else
|
|
228
|
+
consecutive_empty=0
|
|
229
|
+
if [ -n "$current_pids" ]; then
|
|
230
|
+
log_warn "第 $elapsed 秒: 发现进程 $current_pids,再次 kill..."
|
|
231
|
+
pkill -9 -f "openclaw" &>/dev/null || true
|
|
232
|
+
fi
|
|
233
|
+
if check_port "$PORT"; then
|
|
234
|
+
log_warn "第 $elapsed 秒: 端口仍在监听,使用 fuser..."
|
|
235
|
+
if command -v fuser &>/dev/null; then
|
|
236
|
+
fuser -k "${PORT}/tcp" &>/dev/null || true
|
|
237
|
+
fi
|
|
238
|
+
fi
|
|
234
239
|
fi
|
|
240
|
+
|
|
241
|
+
elapsed=$((elapsed + 1))
|
|
242
|
+
done
|
|
243
|
+
|
|
244
|
+
# 最终验证
|
|
245
|
+
local final_pids=""
|
|
246
|
+
if command -v pgrep &>/dev/null; then
|
|
247
|
+
final_pids=$(pgrep -f "openclaw" | tr '\n' ' ')
|
|
248
|
+
fi
|
|
249
|
+
|
|
250
|
+
if [ -n "$final_pids" ] || check_port "$PORT"; then
|
|
251
|
+
log_error "OpenClaw 服务停止失败!进程或端口仍在运行。"
|
|
252
|
+
log_error "剩余进程: $final_pids"
|
|
253
|
+
exit 1
|
|
235
254
|
fi
|
|
236
255
|
|
|
237
256
|
log_info "服务已停止"
|
package/package.json
CHANGED
|
@@ -224,8 +224,9 @@ class RongyunMessageHandler {
|
|
|
224
224
|
// 使用解析后的 content(聊天内容),如果没有则使用原始 content
|
|
225
225
|
const content = data.content || data._raw_content;
|
|
226
226
|
const requestId = data.request_id;
|
|
227
|
+
const sourceId = data.source_im_id;
|
|
227
228
|
|
|
228
|
-
this.logInfo(`[RongyunMessageHandler] 收到聊天消息, roomId=${roomId}, sessionId=${sessionId}`);
|
|
229
|
+
this.logInfo(`[RongyunMessageHandler] 收到聊天消息, roomId=${roomId}, sessionId=${sessionId}, from=${sourceId}`);
|
|
229
230
|
|
|
230
231
|
if (!roomId || !sessionId || !content) {
|
|
231
232
|
await this.sendResponse(RongyunMessageTypeEnum.CHAT_MESSAGE, {
|
|
@@ -233,7 +234,7 @@ class RongyunMessageHandler {
|
|
|
233
234
|
message: '缺少必要参数',
|
|
234
235
|
content: '[错误] 缺少必要参数',
|
|
235
236
|
metadata: {}
|
|
236
|
-
}, requestId);
|
|
237
|
+
}, requestId, sourceId);
|
|
237
238
|
return;
|
|
238
239
|
}
|
|
239
240
|
|
|
@@ -258,7 +259,7 @@ class RongyunMessageHandler {
|
|
|
258
259
|
message: 'Response received',
|
|
259
260
|
content: fullResponse,
|
|
260
261
|
metadata: {}
|
|
261
|
-
}, requestId);
|
|
262
|
+
}, requestId, sourceId);
|
|
262
263
|
} catch (e) {
|
|
263
264
|
const msg = e instanceof Error ? e.message : String(e);
|
|
264
265
|
this.logError(`聊天消息处理异常: ${msg}`);
|
|
@@ -267,15 +268,16 @@ class RongyunMessageHandler {
|
|
|
267
268
|
message: msg,
|
|
268
269
|
content: `[错误] 转发失败: ${msg}`,
|
|
269
270
|
metadata: {}
|
|
270
|
-
}, requestId);
|
|
271
|
+
}, requestId, sourceId);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
async handleCreateSession(data) {
|
|
275
276
|
const requestId = data.request_id;
|
|
276
277
|
const title = data.title || '新会话';
|
|
278
|
+
const sourceId = data.source_im_id;
|
|
277
279
|
|
|
278
|
-
this.logInfo(`[RongyunMessageHandler] 创建会话, title=${title}`);
|
|
280
|
+
this.logInfo(`[RongyunMessageHandler] 创建会话, title=${title}, from=${sourceId}`);
|
|
279
281
|
|
|
280
282
|
try {
|
|
281
283
|
const session = await createOpencodeSession(title);
|
|
@@ -283,14 +285,14 @@ class RongyunMessageHandler {
|
|
|
283
285
|
await this.sendResponse(RongyunMessageTypeEnum.OPENCODE_SESSION_CREATED, {
|
|
284
286
|
status: 'success',
|
|
285
287
|
opencode_session_id: session.id
|
|
286
|
-
}, requestId);
|
|
288
|
+
}, requestId, sourceId);
|
|
287
289
|
} catch (e) {
|
|
288
290
|
const msg = e instanceof Error ? e.message : String(e);
|
|
289
291
|
this.logError(`创建会话失败: ${msg}`);
|
|
290
292
|
await this.sendResponse(RongyunMessageTypeEnum.OPENCODE_SESSION_CREATED, {
|
|
291
293
|
status: 'error',
|
|
292
294
|
message: msg
|
|
293
|
-
}, requestId);
|
|
295
|
+
}, requestId, sourceId);
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
|