mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
support set core priority
This commit is contained in:
parent
9f6aac708b
commit
5bafb7ccc1
11
changelog.md
11
changelog.md
|
@ -7,12 +7,11 @@
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- 支持设置 `direct-nameserver`
|
- 内置 Sub-Store 不使用缓存
|
||||||
- 支持设置 `route-exclude-address`
|
- 允许控制是否为 Sub-Store 使用代理
|
||||||
|
- 允许设置内核进程优先级
|
||||||
|
- 提高进程优先级
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- 不使用pac模式时不再启动pac服务器
|
- 修复寻找可用端口失败的问题
|
||||||
- 修复对话框上层可调整侧栏大小的问题
|
|
||||||
- 修复Windows系统路径错误
|
|
||||||
- 修复内核panic没有日志的问题
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import { readFile, rm, writeFile } from 'fs/promises'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { mainWindow } from '..'
|
import { mainWindow } from '..'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import os from 'os'
|
||||||
import { createWriteStream, existsSync } from 'fs'
|
import { createWriteStream, existsSync } from 'fs'
|
||||||
import { uploadRuntimeConfig } from '../resolve/gistApi'
|
import { uploadRuntimeConfig } from '../resolve/gistApi'
|
||||||
import { startMonitor } from '../resolve/trafficMonitor'
|
import { startMonitor } from '../resolve/trafficMonitor'
|
||||||
|
@ -57,7 +58,12 @@ let child: ChildProcess
|
||||||
let retry = 10
|
let retry = 10
|
||||||
|
|
||||||
export async function startCore(detached = false): Promise<Promise<void>[]> {
|
export async function startCore(detached = false): Promise<Promise<void>[]> {
|
||||||
const { core = 'mihomo', autoSetDNS = true, diffWorkDir = false } = await getAppConfig()
|
const {
|
||||||
|
core = 'mihomo',
|
||||||
|
autoSetDNS = true,
|
||||||
|
diffWorkDir = false,
|
||||||
|
mihomoCpuPriority = 'PRIORITY_HIGHEST'
|
||||||
|
} = await getAppConfig()
|
||||||
const { 'log-level': logLevel } = await getControledMihomoConfig()
|
const { 'log-level': logLevel } = await getControledMihomoConfig()
|
||||||
if (existsSync(path.join(dataDir(), 'core.pid'))) {
|
if (existsSync(path.join(dataDir(), 'core.pid'))) {
|
||||||
const pid = parseInt(await readFile(path.join(dataDir(), 'core.pid'), 'utf-8'))
|
const pid = parseInt(await readFile(path.join(dataDir(), 'core.pid'), 'utf-8'))
|
||||||
|
@ -94,6 +100,9 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
|
||||||
stdio: detached ? 'ignore' : undefined
|
stdio: detached ? 'ignore' : undefined
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if (child.pid) {
|
||||||
|
os.setPriority(child.pid, os.constants.priority[mihomoCpuPriority])
|
||||||
|
}
|
||||||
if (detached) {
|
if (detached) {
|
||||||
child.unref()
|
child.unref()
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|
|
@ -38,7 +38,7 @@ const taskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
||||||
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
||||||
<WakeToRun>false</WakeToRun>
|
<WakeToRun>false</WakeToRun>
|
||||||
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
||||||
<Priority>0</Priority>
|
<Priority>3</Priority>
|
||||||
</Settings>
|
</Settings>
|
||||||
<Actions Context="Author">
|
<Actions Context="Author">
|
||||||
<Exec>
|
<Exec>
|
||||||
|
|
|
@ -90,7 +90,7 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
||||||
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
||||||
<WakeToRun>false</WakeToRun>
|
<WakeToRun>false</WakeToRun>
|
||||||
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
||||||
<Priority>0</Priority>
|
<Priority>3</Priority>
|
||||||
</Settings>
|
</Settings>
|
||||||
<Actions Context="Author">
|
<Actions Context="Author">
|
||||||
<Exec>
|
<Exec>
|
||||||
|
|
|
@ -22,6 +22,7 @@ const MihomoConfig: React.FC = () => {
|
||||||
pauseSSID = [],
|
pauseSSID = [],
|
||||||
delayTestUrl,
|
delayTestUrl,
|
||||||
userAgent,
|
userAgent,
|
||||||
|
mihomoCpuPriority = 'PRIORITY_HIGHEST',
|
||||||
proxyCols = 'auto'
|
proxyCols = 'auto'
|
||||||
} = appConfig || {}
|
} = appConfig || {}
|
||||||
const [url, setUrl] = useState(delayTestUrl)
|
const [url, setUrl] = useState(delayTestUrl)
|
||||||
|
@ -135,6 +136,26 @@ const MihomoConfig: React.FC = () => {
|
||||||
<SelectItem key="4">四列</SelectItem>
|
<SelectItem key="4">四列</SelectItem>
|
||||||
</Select>
|
</Select>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
<SettingItem title="内核进程优先级" divider>
|
||||||
|
<Select
|
||||||
|
classNames={{ trigger: 'data-[hover=true]:bg-default-200' }}
|
||||||
|
className="w-[150px]"
|
||||||
|
size="sm"
|
||||||
|
selectedKeys={new Set([mihomoCpuPriority])}
|
||||||
|
onSelectionChange={async (v) => {
|
||||||
|
await patchAppConfig({
|
||||||
|
mihomoCpuPriority: v.currentKey as Priority
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectItem key="PRIORITY_HIGHEST">实时</SelectItem>
|
||||||
|
<SelectItem key="PRIORITY_HIGH">高</SelectItem>
|
||||||
|
<SelectItem key="PRIORITY_ABOVE_NORMAL">高于正常</SelectItem>
|
||||||
|
<SelectItem key="PRIORITY_NORMAL">正常</SelectItem>
|
||||||
|
<SelectItem key="PRIORITY_BELOW_NORMAL">低于正常</SelectItem>
|
||||||
|
<SelectItem key="PRIORITY_LOW">低</SelectItem>
|
||||||
|
</Select>
|
||||||
|
</SettingItem>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
title="为不同订阅分别指定工作目录"
|
title="为不同订阅分别指定工作目录"
|
||||||
actions={
|
actions={
|
||||||
|
|
8
src/shared/types.d.ts
vendored
8
src/shared/types.d.ts
vendored
|
@ -4,6 +4,13 @@ type SysProxyMode = 'auto' | 'manual'
|
||||||
type CardStatus = 'col-span-2' | 'col-span-1' | 'hidden'
|
type CardStatus = 'col-span-2' | 'col-span-1' | 'hidden'
|
||||||
type AppTheme = 'system' | 'light' | 'dark'
|
type AppTheme = 'system' | 'light' | 'dark'
|
||||||
type MihomoGroupType = 'Selector' | 'URLTest' | 'LoadBalance' | 'Relay'
|
type MihomoGroupType = 'Selector' | 'URLTest' | 'LoadBalance' | 'Relay'
|
||||||
|
type Priority =
|
||||||
|
| 'PRIORITY_LOW'
|
||||||
|
| 'PRIORITY_BELOW_NORMAL'
|
||||||
|
| 'PRIORITY_NORMAL'
|
||||||
|
| 'PRIORITY_ABOVE_NORMAL'
|
||||||
|
| 'PRIORITY_HIGH'
|
||||||
|
| 'PRIORITY_HIGHEST'
|
||||||
type MihomoProxyType =
|
type MihomoProxyType =
|
||||||
| 'Direct'
|
| 'Direct'
|
||||||
| 'Reject'
|
| 'Reject'
|
||||||
|
@ -240,6 +247,7 @@ interface IAppConfig {
|
||||||
autoQuitWithoutCoreDelay?: number
|
autoQuitWithoutCoreDelay?: number
|
||||||
useCustomSubStore?: boolean
|
useCustomSubStore?: boolean
|
||||||
useProxyInSubStore?: boolean
|
useProxyInSubStore?: boolean
|
||||||
|
mihomoCpuPriority?: Priority
|
||||||
customSubStoreUrl?: string
|
customSubStoreUrl?: string
|
||||||
diffWorkDir?: boolean
|
diffWorkDir?: boolean
|
||||||
autoSetDNS?: boolean
|
autoSetDNS?: boolean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user