mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
ignore stdio when detached
This commit is contained in:
parent
e8d52ca681
commit
3449287e46
@ -82,8 +82,15 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
|
||||
}
|
||||
}
|
||||
child = spawn(corePath, ['-d', mihomoWorkDir()], {
|
||||
detached: detached
|
||||
detached: detached,
|
||||
stdio: detached ? 'ignore' : undefined
|
||||
})
|
||||
if (detached) {
|
||||
child.unref()
|
||||
return new Promise((resolve) => {
|
||||
resolve([new Promise(() => {})])
|
||||
})
|
||||
}
|
||||
child.on('close', async (code, signal) => {
|
||||
await writeFile(logPath(), `[Manager]: Core closed, code: ${code}, signal: ${signal}\n`, {
|
||||
flag: 'a'
|
||||
@ -176,13 +183,8 @@ export async function restartCore(): Promise<void> {
|
||||
export async function keepCoreAlive(): Promise<void> {
|
||||
try {
|
||||
await startCore(true)
|
||||
stopMihomoTraffic()
|
||||
stopMihomoConnections()
|
||||
stopMihomoLogs()
|
||||
stopMihomoMemory()
|
||||
if (child && child.pid) {
|
||||
await writeFile(path.join(dataDir(), 'core.pid'), child.pid.toString())
|
||||
child.unref()
|
||||
}
|
||||
} catch (e) {
|
||||
dialog.showErrorBox('内核启动出错', `${e}`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user