diff --git a/apps/processor/Dockerfile b/apps/processor/Dockerfile index bac5de6..463b282 100644 --- a/apps/processor/Dockerfile +++ b/apps/processor/Dockerfile @@ -64,4 +64,16 @@ COPY --from=builder --chown=processor:nodejs /vote-processor /vote-processor WORKDIR /vote-processor -CMD ["node", "node_modules/@sora-vp/processor/dist/index.js"] +COPY < { +export const consumeMessagesFromQueue = async (loggerDirectory: string) => { + const logger = initLogger(loggerDirectory); + try { logger.debug(`[MQ] MQ AMQP: ${env.AMQP_URL}`); logger.debug(`[TRPC] TRPC URL: ${env.PROCESSOR_API_URL}`); @@ -226,5 +228,3 @@ const consumeMessagesFromQueue = async () => { logger.error(error); } }; - -void consumeMessagesFromQueue(); diff --git a/apps/processor/src/logger.ts b/apps/processor/src/logger.ts index 084a247..79624b4 100644 --- a/apps/processor/src/logger.ts +++ b/apps/processor/src/logger.ts @@ -1,29 +1,26 @@ import path from "path"; -import { fileURLToPath } from "url"; import pino from "pino"; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -export const logger = pino({ - transport: { - targets: [ - { - target: "pino-pretty", - level: "debug", - options: { - colorize: true, - ignore: "pid,hostname", - translateTime: "SYS:standard", +export const initLogger = (destinationDirectoryPath: string) => + pino({ + transport: { + targets: [ + { + target: "pino-pretty", + level: "debug", + options: { + colorize: true, + ignore: "pid,hostname", + translateTime: "SYS:standard", + }, }, - }, - { - target: "pino/file", - level: "debug", - options: { - destination: path.join(__dirname, "..", "processor.log"), + { + target: "pino/file", + level: "debug", + options: { + destination: path.join(destinationDirectoryPath, "processor.log"), + }, }, - }, - ], - }, -}); + ], + }, + });