From 94cc2f59c897b1e9de02c5f5b4dbd0919e7591d9 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Mon, 11 Nov 2024 11:39:23 +0800 Subject: [PATCH] catch core panic log --- src/main/core/manager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/core/manager.ts b/src/main/core/manager.ts index 058eb7b..840abad 100644 --- a/src/main/core/manager.ts +++ b/src/main/core/manager.ts @@ -34,7 +34,7 @@ import { readFile, rm, writeFile } from 'fs/promises' import { promisify } from 'util' import { mainWindow } from '..' import path from 'path' -import { existsSync } from 'fs' +import { createWriteStream, existsSync } from 'fs' import { uploadRuntimeConfig } from '../resolve/gistApi' import { startMonitor } from '../resolve/trafficMonitor' @@ -84,7 +84,8 @@ export async function startCore(detached = false): Promise[]> { }) } } - + const stdout = createWriteStream(logPath(), { flags: 'a' }) + const stderr = createWriteStream(logPath(), { flags: 'a' }) child = spawn( corePath, ['-d', diffWorkDir ? mihomoProfileWorkDir(current) : mihomoWorkDir(), ctlParam, mihomoIpcPath], @@ -111,9 +112,8 @@ export async function startCore(detached = false): Promise[]> { await stopCore() } }) - child.stdout?.on('data', async (data) => { - await writeFile(logPath(), data, { flag: 'a' }) - }) + child.stdout?.pipe(stdout) + child.stderr?.pipe(stderr) return new Promise((resolve, reject) => { child.stdout?.on('data', async (data) => { const str = data.toString()