From b77e67c6d6306adb4dfbb1b0865c9bd5c5b9a2f3 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sat, 23 Nov 2024 00:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Efix=EF=BC=9A=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BD=91=E7=BB=9C=E7=9B=91=E6=8E=A7=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 5 ++--- server/app/r/api/bot/route.js | 1 - start-nextjs.js => utils/start-nextjs.js | 5 ++++- 3 files changed, 6 insertions(+), 5 deletions(-) rename start-nextjs.js => utils/start-nextjs.js (92%) diff --git a/index.js b/index.js index c80cc07..8fadf29 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "path"; import config from "./model/config.js"; -import { buildNextJs, startNextJs } from "./start-nextjs.js"; +import { startNextJs } from "./utils/start-nextjs.js"; if (!global.segment) { global.segment = (await import("oicq")).segment } @@ -41,8 +41,7 @@ for (let i in files) { // 检查是否启动 webui if (isOpenWebUI) { - buildNextJs() - .then(() => startNextJs('start')) + startNextJs('dev') } export { apps }; diff --git a/server/app/r/api/bot/route.js b/server/app/r/api/bot/route.js index 9066032..35d92dc 100644 --- a/server/app/r/api/bot/route.js +++ b/server/app/r/api/bot/route.js @@ -1,7 +1,6 @@ import { REDIS_YUNZAI_WEBUI } from "../../../../../constants/constant.js"; import { redis } from "../../../../utils/redis.js"; - export async function GET(req, res) { const botInfo = JSON.parse(await redis.get(REDIS_YUNZAI_WEBUI)); diff --git a/start-nextjs.js b/utils/start-nextjs.js similarity index 92% rename from start-nextjs.js rename to utils/start-nextjs.js index 94181bf..5d4d3b2 100644 --- a/start-nextjs.js +++ b/utils/start-nextjs.js @@ -34,7 +34,7 @@ export const startNextJs = (mode = 'start') => { nextjsProcess = spawn('pnpm', ['run', script], { cwd: './plugins/rconsole-plugin', // 指定工作目录 - stdio: ['ignore', 'ignore', 'ignore', 'ipc'], // 继承父进程的标准输入输出 + stdio: 'ignore', shell: true, }); @@ -43,6 +43,9 @@ export const startNextJs = (mode = 'start') => { logger.error(`[R插件][Next.js监测],Next.js 进程发生异常 ${code}`); nextjsProcess = null; }); + nextjsProcess.on('error', (err) => { + logger.error(`[R插件][Next.js监测] 子进程错误: ${err.message}`); + }); }; // 捕获父进程退出信号