mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-28 05:30:29 +08:00
24 lines
551 B
TypeScript
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()
|
|
}
|