diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts index c2ce1a277..b6020c61c 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts @@ -69,8 +69,8 @@ export async function emitEvent(payload: Omit) { await publishEvent(); } else if (process.env.EVENT_TRANSMISSION === "unix" && process.env.EVENT_SOCKET_PATH) { if (!unixSocketWriter) { - unixSocketWriter = new UnixSocketWriter(process.env.EVENT_SOCKET_PATH); - await unixSocketWriter.init(); + console.error("[Event] Unix socket writer not initialized, cannot emit event!"); + throw new Error("Unix socket writer not initialized"); } await unixSocketWriter.emit(payload); } else if (process.env.EVENT_TRANSMISSION === "process") { @@ -83,6 +83,13 @@ export async function emitEvent(payload: Omit) { export async function initEvent() { await RabbitMQ.init(); // does nothing if rabbitmq is not setup + if (process.env.EVENT_TRANSMISSION === "unix" && process.env.EVENT_SOCKET_PATH) { + if (!unixSocketWriter) { + unixSocketWriter = new UnixSocketWriter(process.env.EVENT_SOCKET_PATH); + await unixSocketWriter.init(); + } + } + // Set up the spacebar event listener (used for config reload, etc.) const setupSpacebarListener = async () => { console.log("[Event] Setting up spacebar event listener");