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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user