Add process restart feature via WebUI

Introduces backend and frontend support for restarting the worker process from the WebUI. Adds API endpoint, controller, and UI button for process management. Refactors napcat-shell to support master/worker process lifecycle and restart logic.
This commit is contained in:
手瓜一十雪
2026-01-17 14:42:07 +08:00
parent 7c22170e1e
commit 3e8b575015
10 changed files with 338 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
import type { Request, Response } from 'express';
import { WebUiDataRuntime } from '../helper/Data';
import { sendError, sendSuccess } from '../utils/response';
/**
* 重启进程处理器
* POST /api/Process/Restart
*/
export async function RestartProcessHandler (_req: Request, res: Response) {
try {
const result = await WebUiDataRuntime.requestRestartProcess();
if (result.result) {
return sendSuccess(res, { message: result.message || '进程重启请求已发送' });
} else {
return sendError(res, result.message || '进程重启失败', 500);
}
} catch (e) {
return sendError(res, '重启进程时发生错误: ' + (e as Error).message, 500);
}
}