🐞fix:暂时解决网络监控失效问题

This commit is contained in:
zhiyu1998 2024-11-23 00:14:59 +08:00
parent 8a6b9339e7
commit b77e67c6d6
3 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import fs from "node:fs"; import fs from "node:fs";
import path from "path"; import path from "path";
import config from "./model/config.js"; import config from "./model/config.js";
import { buildNextJs, startNextJs } from "./start-nextjs.js"; import { startNextJs } from "./utils/start-nextjs.js";
if (!global.segment) { if (!global.segment) {
global.segment = (await import("oicq")).segment global.segment = (await import("oicq")).segment
} }
@ -41,8 +41,7 @@ for (let i in files) {
// 检查是否启动 webui // 检查是否启动 webui
if (isOpenWebUI) { if (isOpenWebUI) {
buildNextJs() startNextJs('dev')
.then(() => startNextJs('start'))
} }
export { apps }; export { apps };

View File

@ -1,7 +1,6 @@
import { REDIS_YUNZAI_WEBUI } from "../../../../../constants/constant.js"; import { REDIS_YUNZAI_WEBUI } from "../../../../../constants/constant.js";
import { redis } from "../../../../utils/redis.js"; import { redis } from "../../../../utils/redis.js";
export async function GET(req, res) { export async function GET(req, res) {
const botInfo = JSON.parse(await redis.get(REDIS_YUNZAI_WEBUI)); const botInfo = JSON.parse(await redis.get(REDIS_YUNZAI_WEBUI));

View File

@ -34,7 +34,7 @@ export const startNextJs = (mode = 'start') => {
nextjsProcess = spawn('pnpm', ['run', script], { nextjsProcess = spawn('pnpm', ['run', script], {
cwd: './plugins/rconsole-plugin', // 指定工作目录 cwd: './plugins/rconsole-plugin', // 指定工作目录
stdio: ['ignore', 'ignore', 'ignore', 'ipc'], // 继承父进程的标准输入输出 stdio: 'ignore',
shell: true, shell: true,
}); });
@ -43,6 +43,9 @@ export const startNextJs = (mode = 'start') => {
logger.error(`[R插件][Next.js监测]Next.js 进程发生异常 ${code}`); logger.error(`[R插件][Next.js监测]Next.js 进程发生异常 ${code}`);
nextjsProcess = null; nextjsProcess = null;
}); });
nextjsProcess.on('error', (err) => {
logger.error(`[R插件][Next.js监测] 子进程错误: ${err.message}`);
});
}; };
// 捕获父进程退出信号 // 捕获父进程退出信号