Keep daemon logs after a button restart
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { closeSync, openSync } from "node:fs";
|
||||
import { config as loadEnv } from "dotenv";
|
||||
import { createMcpExpressApp } from "@modelcontextprotocol/sdk/server/express.js";
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
@@ -1051,14 +1052,18 @@ function restartDaemon(): void {
|
||||
const args = [...process.execArgv, ...process.argv.slice(1)];
|
||||
const command = `${quote(process.execPath)} ${args.map(quote).join(" ")}`;
|
||||
|
||||
console.log("[daemon] restart requested: spawning a replacement");
|
||||
const logPath = process.env.VESKSLOP_DAEMON_LOG ?? join(dirname(tokenFile), "daemon.log");
|
||||
console.log(`[daemon] restart requested: spawning a replacement, appending to ${logPath}`);
|
||||
|
||||
const logFd = openSync(logPath, "a");
|
||||
const child = spawn("sh", ["-c", `sleep 2; exec ${command}`], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
stdio: ["ignore", logFd, logFd],
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, VESKSLOP_DAEMON_RESTART: "1" }
|
||||
});
|
||||
child.unref();
|
||||
closeSync(logFd);
|
||||
|
||||
setTimeout(() => shutdown(true), 300);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user