mihomo-party/src/main/manager.ts
2024-08-07 09:50:11 +08:00

24 lines
551 B
TypeScript

import { execFile, ChildProcess } from 'child_process'
import { mihomoCorePath, mihomoWorkDir } from './dirs'
import { generateProfile } from './factory'
import { appConfig } from './config'
let child: ChildProcess
export function startCore(): void {
const corePath = mihomoCorePath(appConfig.core ?? 'mihomo')
generateProfile()
stopCore()
child = execFile(corePath, ['-d', mihomoWorkDir()], () => {})
}
export function stopCore(): void {
if (child) {
child.kill('SIGINT')
}
}
export function restartCore(): void {
startCore()
}