Upload files to "src/utils"

This commit is contained in:
2026-07-03 00:10:55 +00:00
parent d3442c04ac
commit 0c19e8ff9e
4 changed files with 220 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { spawn } from "child_process";
import { logUtil } from "./logger";
export function daemonize(): boolean {
if (process.env["__DAEMONIZED"]) {
return false;
}
const child = spawn(process.execPath, process.argv.slice(1), {
detached: true,
stdio: "ignore",
cwd: process.cwd(), // or a specific directory
env: { ...process.env, __DAEMONIZED: "1" },
});
child.on("error", (err) => {
logUtil.log(`Failed to background: ${err.message}`);
});
child.unref();
if (child.pid) {
logUtil.log(`Backgrounded with PID ${child.pid}`);
}
return true;
}