mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix: unexpected lightmode core exit
This commit is contained in:
parent
75db218888
commit
66a41306d6
@ -153,6 +153,7 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
|
|||||||
os.setPriority(child.pid, os.constants.priority[mihomoCpuPriority])
|
os.setPriority(child.pid, os.constants.priority[mihomoCpuPriority])
|
||||||
}
|
}
|
||||||
if (detached) {
|
if (detached) {
|
||||||
|
await managerLogger.info(`Core process detached successfully on ${process.platform}, PID: ${child.pid}`)
|
||||||
child.unref()
|
child.unref()
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolve([new Promise(() => {})])
|
resolve([new Promise(() => {})])
|
||||||
@ -388,8 +389,21 @@ export async function keepCoreAlive(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function quitWithoutCore(): Promise<void> {
|
export async function quitWithoutCore(): Promise<void> {
|
||||||
await keepCoreAlive()
|
await managerLogger.info(`Starting lightweight mode on platform: ${process.platform}`)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await startCore(true)
|
||||||
|
if (child && child.pid) {
|
||||||
|
await writeFile(path.join(dataDir(), 'core.pid'), child.pid.toString())
|
||||||
|
await managerLogger.info(`Core started in lightweight mode with PID: ${child.pid}`)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
await managerLogger.error('Failed to start core in lightweight mode:', e)
|
||||||
|
safeShowErrorBox('mihomo.error.coreStartFailed', `${e}`)
|
||||||
|
}
|
||||||
|
|
||||||
await startMonitor(true)
|
await startMonitor(true)
|
||||||
|
await managerLogger.info('Exiting main process, core will continue running in background')
|
||||||
app.exit()
|
app.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user