From 9204a8ab30221b29bc2488382978c25fbcbdaf7d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 3 May 2024 08:15:56 -0400 Subject: [PATCH] fix: Duplicate plugin registration logging in debug --- server/index.ts | 2 +- server/utils/PluginManager.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/index.ts b/server/index.ts index 0e5b89d86..4fbc3edb7 100644 --- a/server/index.ts +++ b/server/index.ts @@ -59,7 +59,7 @@ async function master() { } // This function will only be called in each forked process -async function start(id: number, disconnect: () => void) { +async function start(_id: number, disconnect: () => void) { // Ensure plugins are loaded PluginManager.loadPlugins(); diff --git a/server/utils/PluginManager.ts b/server/utils/PluginManager.ts index 1f3521cdb..4634e3ae0 100644 --- a/server/utils/PluginManager.ts +++ b/server/utils/PluginManager.ts @@ -81,12 +81,16 @@ export class PluginManager { .get(plugin.type)! .push({ ...plugin, priority: plugin.priority ?? PluginPriority.Normal }); - Logger.debug( - "plugins", - `Plugin(type=${plugin.type}) registered ${ - "name" in plugin.value ? plugin.value.name : "" - } ${plugin.description ? `(${plugin.description})` : ""}` - ); + // Do not log plugin registration in forked worker processes, one log from the master process + // is enough. This can be detected by the presence of `process.send`. + if (process.send === undefined) { + Logger.debug( + "plugins", + `Plugin(type=${plugin.type}) registered ${ + "name" in plugin.value ? plugin.value.name : "" + } ${plugin.description ? `(${plugin.description})` : ""}` + ); + } } /**