mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 18:15:41 +00:00
IPC: eagerly init unix sockets on startup
This commit is contained in:
@@ -69,8 +69,8 @@ export async function emitEvent(payload: Omit<Event, "created_at">) {
|
||||
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<Event, "created_at">) {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user