@vm0/runner 3.12.3 → 3.13.0
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/index.js +24 -24
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -429,6 +429,26 @@ function isProcessRunning(pid) {
|
|
|
429
429
|
return false;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
+
async function gracefulKillProcess(pid, timeoutMs = 5e3) {
|
|
433
|
+
if (!isProcessRunning(pid)) return true;
|
|
434
|
+
try {
|
|
435
|
+
process.kill(pid, "SIGTERM");
|
|
436
|
+
} catch {
|
|
437
|
+
return !isProcessRunning(pid);
|
|
438
|
+
}
|
|
439
|
+
const startTime = Date.now();
|
|
440
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
441
|
+
if (!isProcessRunning(pid)) return true;
|
|
442
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
443
|
+
}
|
|
444
|
+
if (isProcessRunning(pid)) {
|
|
445
|
+
try {
|
|
446
|
+
process.kill(pid, "SIGKILL");
|
|
447
|
+
} catch {
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return !isProcessRunning(pid);
|
|
451
|
+
}
|
|
432
452
|
function killProcessTree(pid) {
|
|
433
453
|
try {
|
|
434
454
|
const childPidsStr = execSync(`pgrep -P ${pid} 2>/dev/null || true`, {
|
|
@@ -9935,7 +9955,7 @@ async function executeJob(context, config, options = {}) {
|
|
|
9935
9955
|
logger9.log(`Guest client ready`);
|
|
9936
9956
|
if (config.firecracker.snapshot) {
|
|
9937
9957
|
const timestamp = (Date.now() / 1e3).toFixed(3);
|
|
9938
|
-
await guest.exec(`date -s "@${timestamp}"`);
|
|
9958
|
+
await guest.exec(`sudo date -s "@${timestamp}"`);
|
|
9939
9959
|
}
|
|
9940
9960
|
if (context.storageManifest) {
|
|
9941
9961
|
await withSandboxTiming(
|
|
@@ -9994,7 +10014,7 @@ async function executeJob(context, config, options = {}) {
|
|
|
9994
10014
|
const duration = Math.round(durationMs / 1e3);
|
|
9995
10015
|
if (exitCode === 137 || exitCode === 9) {
|
|
9996
10016
|
const dmesgCheck = await guest.exec(
|
|
9997
|
-
`dmesg | tail -20 | grep -iE "killed|oom" 2>/dev/null`
|
|
10017
|
+
`sudo dmesg | tail -20 | grep -iE "killed|oom" 2>/dev/null`
|
|
9998
10018
|
);
|
|
9999
10019
|
if (dmesgCheck.stdout.toLowerCase().includes("oom") || dmesgCheck.stdout.toLowerCase().includes("killed")) {
|
|
10000
10020
|
logger9.log(`OOM detected: ${dmesgCheck.stdout}`);
|
|
@@ -10587,26 +10607,6 @@ function findProcessByVmId(vmId) {
|
|
|
10587
10607
|
const vmIdStr = vmIdValue(vmId);
|
|
10588
10608
|
return processes.find((p) => vmIdValue(p.vmId) === vmIdStr) || null;
|
|
10589
10609
|
}
|
|
10590
|
-
async function killProcess(pid, timeoutMs = 5e3) {
|
|
10591
|
-
if (!isProcessRunning(pid)) return true;
|
|
10592
|
-
try {
|
|
10593
|
-
process.kill(pid, "SIGTERM");
|
|
10594
|
-
} catch {
|
|
10595
|
-
return !isProcessRunning(pid);
|
|
10596
|
-
}
|
|
10597
|
-
const startTime = Date.now();
|
|
10598
|
-
while (Date.now() - startTime < timeoutMs) {
|
|
10599
|
-
if (!isProcessRunning(pid)) return true;
|
|
10600
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
10601
|
-
}
|
|
10602
|
-
if (isProcessRunning(pid)) {
|
|
10603
|
-
try {
|
|
10604
|
-
process.kill(pid, "SIGKILL");
|
|
10605
|
-
} catch {
|
|
10606
|
-
}
|
|
10607
|
-
}
|
|
10608
|
-
return !isProcessRunning(pid);
|
|
10609
|
-
}
|
|
10610
10610
|
function findMitmproxyProcesses() {
|
|
10611
10611
|
const processes = [];
|
|
10612
10612
|
const procDir = "/proc";
|
|
@@ -10900,7 +10900,7 @@ var killCommand = new Command3("kill").description("Force terminate a run and cl
|
|
|
10900
10900
|
}
|
|
10901
10901
|
const results = [];
|
|
10902
10902
|
if (proc) {
|
|
10903
|
-
const killed = await
|
|
10903
|
+
const killed = await gracefulKillProcess(proc.pid);
|
|
10904
10904
|
results.push({
|
|
10905
10905
|
step: "Firecracker process",
|
|
10906
10906
|
success: killed,
|
|
@@ -11345,7 +11345,7 @@ var snapshotCommand = new Command5("snapshot").description("Generate a Firecrack
|
|
|
11345
11345
|
);
|
|
11346
11346
|
|
|
11347
11347
|
// src/index.ts
|
|
11348
|
-
var version = true ? "3.
|
|
11348
|
+
var version = true ? "3.13.0" : "0.1.0";
|
|
11349
11349
|
program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
|
|
11350
11350
|
program.addCommand(startCommand);
|
|
11351
11351
|
program.addCommand(doctorCommand);
|