diff --git a/runner/config/default.js b/runner/config/default.js index 93684e8406..b2944f764a 100644 --- a/runner/config/default.js +++ b/runner/config/default.js @@ -133,7 +133,6 @@ module.exports = { * Failure queue */ enableQueueService: false, - queueDatabaseUrl: "", - queueDatabasePassword: "", + // queueDatabaseUrl: "mysql://root:root@localhost:3306/queue" queueServicePollingInterval: "500", }; diff --git a/runner/config/development.json b/runner/config/development.json index 3188e76393..be126c8611 100644 --- a/runner/config/development.json +++ b/runner/config/development.json @@ -2,7 +2,5 @@ "isTest": true, "previewMode": true, "enforceCsrf": false, - "env": "development", - "enableQueueService": true, - "queueDatabaseUrl": "mysql://root:root@localhost:3306/queue" + "env": "development" } diff --git a/runner/src/server/prismaClient.ts b/runner/src/server/prismaClient.ts index f8ece3aaeb..1863e5b6c3 100644 --- a/runner/src/server/prismaClient.ts +++ b/runner/src/server/prismaClient.ts @@ -33,32 +33,38 @@ export const prisma: PrismaClient = new PrismaClient({ log: logLevel, }); -prisma.$connect().catch((error) => { - prismaLogger.error(`Prisma Connect Error ${error.message}`); -}); +if (config.enableQueueService) { + prismaLogger.info("ENABLE_QUEUE_SERVICE is true, connecting to Prisma"); + prisma.$connect().catch((error) => { + prismaLogger.fatal( + `ENABLE_QUEUE_SERVICE is set to true, but Prisma failed to connect ${error}, exiting with status 1` + ); + process.exit(1); + }); -process.on("query", (e: Prisma.QueryEvent) => { - if (!config.isTest) { - prismaLogger.info(` + process.on("query", (e: Prisma.QueryEvent) => { + if (!config.isTest) { + prismaLogger.info(` Prisma Query: ${e.query} \r\n Duration: ${e.duration}ms \r\n Params: ${e.params} `); - } -}); + } + }); -process.on("warn", (e) => { - prismaLogger.warn(e); -}); + process.on("warn", (e) => { + prismaLogger.warn(e); + }); -process.on("info", (e) => { - prismaLogger.info(e); -}); + process.on("info", (e) => { + prismaLogger.info(e); + }); -process.on("error", (e) => { - prismaLogger.error(e); -}); + process.on("error", (e) => { + prismaLogger.error(e); + }); -process.on("beforeExit", () => { - prismaLogger.info("Prisma is exiting"); -}); + process.on("beforeExit", () => { + prismaLogger.info("Prisma is exiting"); + }); +} diff --git a/runner/src/server/utils/configSchema.ts b/runner/src/server/utils/configSchema.ts index e9590e7c74..99e78b0b8b 100644 --- a/runner/src/server/utils/configSchema.ts +++ b/runner/src/server/utils/configSchema.ts @@ -101,6 +101,18 @@ export const configSchema = Joi.object({ "HS512" ) .default("HS512"), + + enableQueueService: Joi.boolean().optional(), + queueDatabaseUrl: Joi.string().when("enableQueueService", { + is: true, + then: Joi.required(), + otherwise: Joi.optional().allow(""), + }), + queueServicePollingInterval: Joi.number().when("enableQueueService", { + is: true, + then: Joi.required(), + otherwise: Joi.optional(), + }), }); export function buildConfig(config) {