17 lines
814 B
TypeScript
17 lines
814 B
TypeScript
/** # 调试脚本:复算杀伤误判(服务器上一次性使用) **/
|
|
const fs = require("fs");
|
|
const launched = JSON.parse(await Bun.file("data/test1-launched.json").text());
|
|
const alive = new Set<string>();
|
|
for (const pid of fs.readdirSync("/proc").filter((d) => /^\d+$/.test(d))) {
|
|
try {
|
|
const cmd = fs.readFileSync(`/proc/${pid}/cmdline`, "utf8");
|
|
const m = /--user-data-dir=\S*\/profiles\/([\w.]+)\/browser/.exec(cmd);
|
|
if (m) alive.add(m[1]);
|
|
} catch { /* ignore */ }
|
|
}
|
|
console.log("alive trees:", alive.size);
|
|
const dead = launched.filter((e: any) => Date.now() - Date.parse(e.startedAt) > 60000 && !alive.has(e.fp));
|
|
console.log("dead count:", dead.length, dead.slice(0, 5).map((e: any) => e.fp));
|
|
const sample = launched[0] && [...alive].slice(0, 5);
|
|
console.log("alive sample:", sample);
|