From 0f899e38aec84253c4775c8d40808375c1f30881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Mon, 9 Mar 2026 06:36:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker):=20Gateway=E7=94=A8exec=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3nohup=E5=90=AF=E5=8A=A8,=E9=98=B2=E6=AD=A2SIGTERM?= =?UTF-8?q?=E6=9D=80=E6=AD=BB=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/dev-api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/dev-api.js b/scripts/dev-api.js index e341a90..ee2094d 100644 --- a/scripts/dev-api.js +++ b/scripts/dev-api.js @@ -1282,8 +1282,10 @@ const handlers = { try { // entrypoint 会 sed 注入 gateway.host(OpenClaw 不认识),doctor --fix 清理 await cExec('openclaw doctor --fix 2>/dev/null || true') - // 停止旧 Gateway,启动新的(合并为一条命令确保 exec 会话存活足够久) - await cExec('pkill -f openclaw-gateway 2>/dev/null; pkill -f "openclaw gateway" 2>/dev/null; sleep 1; mkdir -p /root/.openclaw/logs; nohup openclaw gateway >> /root/.openclaw/logs/gateway.log 2>&1 & sleep 3') + // 停止旧 Gateway + await cExec('pkill -f openclaw-gateway 2>/dev/null; pkill -f "openclaw gateway" 2>/dev/null; sleep 1') + // 启动新 Gateway — 作为独立 Detach exec 的主进程(不能 nohup &,shell 退出会 SIGTERM 杀子进程) + await cExec('mkdir -p /root/.openclaw/logs && exec openclaw gateway >> /root/.openclaw/logs/gateway.log 2>&1') console.log(`[init-worker] Gateway 已重启 → ${containerId.slice(0, 12)}`) } catch (e) { console.warn(`[init-worker] Gateway 重启失败: ${e.message}`)