Disable file logging in main process

Prevent the main process from writing logs to file when running in multi-process mode. base.ts and napcat.ts now disable file logging unless the process is a worker or multi-process mode is disabled (checks NAPCAT_WORKER_PROCESS / NAPCAT_DISABLE_MULTI_PROCESS and ENV.isWorkerProcess / ENV.isMultiProcessDisabled). This reduces duplicate log output and disk I/O by ensuring only worker processes write log files.
This commit is contained in:
手瓜一十雪
2026-03-05 14:56:33 +08:00
parent 7fc70bc5ce
commit 03dd89add0
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -581,6 +581,9 @@ export async function NCoreInitShell () {
console.log('NapCat Shell App Loading...');
const pathWrapper = new NapCatPathWrapper();
const logger = new LogWrapper(pathWrapper.logsPath);
if (process.env['NAPCAT_WORKER_PROCESS'] !== '1' && process.env['NAPCAT_DISABLE_MULTI_PROCESS'] !== '1') {
logger.setFileLogEnabled(false);
}
handleUncaughtExceptions(logger);
await applyPendingUpdates(pathWrapper, logger);
+3
View File
@@ -52,6 +52,9 @@ interface WorkerMessage {
const logger = new LogWrapper(pathWrapper.logsPath);
if (!ENV.isWorkerProcess && !ENV.isMultiProcessDisabled) {
logger.setFileLogEnabled(false);
}
// 进程管理器和当前 Worker 进程引用
let processManager: IProcessManager | null = null;