chatroom-cli 1.37.1 → 1.37.2
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/dist/index.js +53 -29
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -59059,7 +59059,7 @@ async function onCommandRun(ctx, event) {
|
|
|
59059
59059
|
} else {
|
|
59060
59060
|
child.kill("SIGKILL");
|
|
59061
59061
|
}
|
|
59062
|
-
},
|
|
59062
|
+
}, SIGTERM_GRACE_PERIOD_MS);
|
|
59063
59063
|
}, DEFAULT_COMMAND_TIMEOUT_MS);
|
|
59064
59064
|
timeoutTimer.unref?.();
|
|
59065
59065
|
const tracked = {
|
|
@@ -59129,13 +59129,42 @@ async function onCommandRun(ctx, event) {
|
|
|
59129
59129
|
}
|
|
59130
59130
|
});
|
|
59131
59131
|
}
|
|
59132
|
+
function killProcess(child, signal) {
|
|
59133
|
+
const pid = child.pid;
|
|
59134
|
+
if (pid) {
|
|
59135
|
+
try {
|
|
59136
|
+
process.kill(-pid, signal);
|
|
59137
|
+
return;
|
|
59138
|
+
} catch {}
|
|
59139
|
+
}
|
|
59140
|
+
try {
|
|
59141
|
+
child.kill(signal);
|
|
59142
|
+
} catch {}
|
|
59143
|
+
}
|
|
59144
|
+
function waitForExit(runIdStr, ms) {
|
|
59145
|
+
return new Promise((resolve5) => {
|
|
59146
|
+
const interval = 100;
|
|
59147
|
+
let elapsed = 0;
|
|
59148
|
+
const timer = setInterval(() => {
|
|
59149
|
+
if (!runningProcesses.has(runIdStr)) {
|
|
59150
|
+
clearInterval(timer);
|
|
59151
|
+
resolve5(true);
|
|
59152
|
+
return;
|
|
59153
|
+
}
|
|
59154
|
+
elapsed += interval;
|
|
59155
|
+
if (elapsed >= ms) {
|
|
59156
|
+
clearInterval(timer);
|
|
59157
|
+
resolve5(false);
|
|
59158
|
+
}
|
|
59159
|
+
}, interval);
|
|
59160
|
+
});
|
|
59161
|
+
}
|
|
59132
59162
|
async function onCommandStop(ctx, event) {
|
|
59133
59163
|
const runIdStr = event.runId.toString();
|
|
59134
59164
|
const tracked = runningProcesses.get(runIdStr);
|
|
59135
59165
|
if (!tracked) {
|
|
59136
|
-
console.log(`[${formatTimestamp()}] ⚠️ No running process found for run: ${runIdStr}`);
|
|
59166
|
+
console.log(`[${formatTimestamp()}] ⚠️ No running process found for run: ${runIdStr} — marking as stopped`);
|
|
59137
59167
|
pendingStops.set(runIdStr, Date.now());
|
|
59138
|
-
console.log(`[${formatTimestamp()}] \uD83D\uDCDD Registered pending stop for run: ${runIdStr}`);
|
|
59139
59168
|
try {
|
|
59140
59169
|
await ctx.deps.backend.mutation(api.commands.updateRunStatus, {
|
|
59141
59170
|
sessionId: ctx.sessionId,
|
|
@@ -59143,9 +59172,8 @@ async function onCommandStop(ctx, event) {
|
|
|
59143
59172
|
runId: event.runId,
|
|
59144
59173
|
status: "stopped"
|
|
59145
59174
|
});
|
|
59146
|
-
console.log(`[${formatTimestamp()}] \uD83D\uDCDD Marked orphaned run as stopped: ${runIdStr}`);
|
|
59147
59175
|
} catch (err) {
|
|
59148
|
-
console.warn(`[${formatTimestamp()}] ⚠️ Failed to mark
|
|
59176
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Failed to mark run as stopped (will retry): ${getErrorMessage(err)}`);
|
|
59149
59177
|
throw err;
|
|
59150
59178
|
}
|
|
59151
59179
|
return;
|
|
@@ -59155,30 +59183,26 @@ async function onCommandStop(ctx, event) {
|
|
|
59155
59183
|
clearTimeout(tracked.timeoutTimer);
|
|
59156
59184
|
tracked.timeoutTimer = null;
|
|
59157
59185
|
}
|
|
59158
|
-
|
|
59159
|
-
|
|
59160
|
-
|
|
59161
|
-
process.kill(-pid, "SIGTERM");
|
|
59162
|
-
} catch {
|
|
59163
|
-
tracked.process.kill("SIGTERM");
|
|
59164
|
-
}
|
|
59165
|
-
} else {
|
|
59166
|
-
tracked.process.kill("SIGTERM");
|
|
59167
|
-
}
|
|
59168
|
-
setTimeout(() => {
|
|
59169
|
-
if (!runningProcesses.has(runIdStr))
|
|
59170
|
-
return;
|
|
59186
|
+
killProcess(tracked.process, "SIGTERM");
|
|
59187
|
+
const exitedAfterSigterm = await waitForExit(runIdStr, SIGTERM_GRACE_PERIOD_MS);
|
|
59188
|
+
if (!exitedAfterSigterm) {
|
|
59171
59189
|
console.log(`[${formatTimestamp()}] \uD83D\uDD2A Force-killing process: ${runIdStr}`);
|
|
59172
|
-
|
|
59173
|
-
|
|
59174
|
-
|
|
59175
|
-
}
|
|
59176
|
-
tracked.process.kill("SIGKILL");
|
|
59177
|
-
}
|
|
59178
|
-
} else {
|
|
59179
|
-
tracked.process.kill("SIGKILL");
|
|
59190
|
+
killProcess(tracked.process, "SIGKILL");
|
|
59191
|
+
const exitedAfterSigkill = await waitForExit(runIdStr, 1000);
|
|
59192
|
+
if (!exitedAfterSigkill) {
|
|
59193
|
+
console.error(`[${formatTimestamp()}] ❌ Failed to stop process for run: ${runIdStr} — process did not exit after SIGKILL`);
|
|
59180
59194
|
}
|
|
59181
|
-
}
|
|
59195
|
+
}
|
|
59196
|
+
try {
|
|
59197
|
+
await ctx.deps.backend.mutation(api.commands.updateRunStatus, {
|
|
59198
|
+
sessionId: ctx.sessionId,
|
|
59199
|
+
machineId: ctx.machineId,
|
|
59200
|
+
runId: event.runId,
|
|
59201
|
+
status: "stopped"
|
|
59202
|
+
});
|
|
59203
|
+
} catch (err) {
|
|
59204
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Failed to mark run as stopped in backend: ${getErrorMessage(err)}`);
|
|
59205
|
+
}
|
|
59182
59206
|
}
|
|
59183
59207
|
async function shutdownAllCommands(ctx) {
|
|
59184
59208
|
if (runningProcesses.size === 0)
|
|
@@ -59219,7 +59243,7 @@ async function shutdownAllCommands(ctx) {
|
|
|
59219
59243
|
runningProcesses.clear();
|
|
59220
59244
|
console.log(`[${formatTimestamp()}] All commands stopped`);
|
|
59221
59245
|
}
|
|
59222
|
-
var runningProcesses, pendingStops, PENDING_STOP_TTL_MS = 60000, OUTPUT_FLUSH_INTERVAL_MS = 3000, MAX_BUFFER_SIZE, DEFAULT_COMMAND_TIMEOUT_MS,
|
|
59246
|
+
var runningProcesses, pendingStops, PENDING_STOP_TTL_MS = 60000, OUTPUT_FLUSH_INTERVAL_MS = 3000, MAX_BUFFER_SIZE, DEFAULT_COMMAND_TIMEOUT_MS, SIGTERM_GRACE_PERIOD_MS = 5000;
|
|
59223
59247
|
var init_command_runner = __esm(() => {
|
|
59224
59248
|
init_api3();
|
|
59225
59249
|
init_convex_error();
|
|
@@ -62168,5 +62192,5 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
62168
62192
|
});
|
|
62169
62193
|
program2.parse();
|
|
62170
62194
|
|
|
62171
|
-
//# debugId=
|
|
62195
|
+
//# debugId=967EF2E82583BAE364756E2164756E21
|
|
62172
62196
|
//# sourceMappingURL=index.js.map
|