Merge pull request #3376 from overleaf/em-queues-init

Do not create queues on module import

GitOrigin-RevId: b040ac2ab84adb22046d94522b37ef0e59ae165f
This commit is contained in:
Eric Mc Sween 2020-11-12 09:09:41 -05:00 committed by Copybot
parent 6279ab6a91
commit 0ab9c1aa67
2 changed files with 13 additions and 6 deletions

View file

@ -25,6 +25,9 @@ if ((Settings.sentry != null ? Settings.sentry.dsn : undefined) != null) {
metrics.memory.monitor(logger)
const Server = require('./app/src/infrastructure/Server')
const mongodb = require('./app/src/infrastructure/mongodb')
const Queues = require('./app/src/infrastructure/Queues')
Queues.initialize()
if (Settings.catchErrors) {
process.removeAllListeners('uncaughtException')

View file

@ -1,6 +1,15 @@
const Queue = require('bull')
const Settings = require('settings-sharelatex')
const analyticsQueues = {}
function initialize() {
if (Settings.analytics.enabled) {
analyticsQueues.events = createQueue('analytics-events')
analyticsQueues.editingSessions = createQueue('analytics-editing-sessions')
}
}
function createQueue(queueName, defaultJobOptions) {
return new Queue(queueName, {
redis: Settings.redis.queues,
@ -15,9 +24,4 @@ function createQueue(queueName, defaultJobOptions) {
})
}
module.exports = {
analytics: {
events: createQueue('analytics-events'),
editingSessions: createQueue('analytics-editing-sessions')
}
}
module.exports = { initialize, analytics: analyticsQueues }