chatccc 0.2.97 → 0.2.98
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/package.json +1 -1
- package/src/orchestrator.ts +22 -2
package/package.json
CHANGED
package/src/orchestrator.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { readdir, stat } from "node:fs/promises";
|
|
|
10
10
|
import { resolve, dirname } from "node:path";
|
|
11
11
|
|
|
12
12
|
import { makeTraceId, logTrace } from "./trace.ts";
|
|
13
|
+
import { appendStartupTrace } from "./shared.ts";
|
|
13
14
|
import {
|
|
14
15
|
CLAUDE_EFFORT,
|
|
15
16
|
CLAUDE_MODEL,
|
|
@@ -138,15 +139,34 @@ export async function handleCommand(
|
|
|
138
139
|
logTrace(tid, "BRANCH", { cmd: "/restart" });
|
|
139
140
|
await platform.sendText(chatId, "重启中...请几秒后发消息唤醒我").catch(() => {});
|
|
140
141
|
logTrace(tid, "DONE", { outcome: "restart" });
|
|
141
|
-
|
|
142
|
+
|
|
143
|
+
appendStartupTrace("restart: spawn begin", { fromPid: process.pid });
|
|
142
144
|
const child = spawn("npx", ["tsx", "src/index.ts"], {
|
|
143
145
|
cwd: PROJECT_ROOT,
|
|
144
146
|
detached: true,
|
|
145
147
|
stdio: "ignore",
|
|
146
148
|
shell: true,
|
|
147
149
|
});
|
|
150
|
+
|
|
151
|
+
child.on("error", (err) => {
|
|
152
|
+
appendStartupTrace("restart: spawn error", { error: err.message });
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
child.on("exit", (code, signal) => {
|
|
156
|
+
appendStartupTrace("restart: child exit", {
|
|
157
|
+
childPid: child.pid,
|
|
158
|
+
code,
|
|
159
|
+
signal,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
148
163
|
child.unref();
|
|
149
|
-
|
|
164
|
+
|
|
165
|
+
// 给子进程 2 秒启动窗口,期间若立即 crash 则 exit handler 已写入 trace
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
appendStartupTrace("restart: parent exit", { childPid: child.pid });
|
|
168
|
+
process.exit(0);
|
|
169
|
+
}, 2000);
|
|
150
170
|
return;
|
|
151
171
|
}
|
|
152
172
|
|