fix: localization master callback + various fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const _ = require('lodash')
|
||||
const EventEmitter = require('events')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
@@ -23,6 +24,8 @@ module.exports = {
|
||||
await WIKI.models.onReady
|
||||
await WIKI.configSvc.loadFromDb()
|
||||
await WIKI.queue.clean()
|
||||
WIKI.events = new EventEmitter()
|
||||
WIKI.redisSub = require('./redis').subscribe()
|
||||
} catch (err) {
|
||||
WIKI.logger.error(err)
|
||||
process.exit(1)
|
||||
|
@@ -33,6 +33,15 @@ module.exports = {
|
||||
// Load current language + namespaces
|
||||
this.refreshNamespaces(true)
|
||||
|
||||
// Listen for localization events
|
||||
WIKI.events.on('localization', (action) => {
|
||||
switch (action) {
|
||||
case 'reload':
|
||||
this.refreshNamespaces()
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
return this
|
||||
},
|
||||
attachMiddleware (app) {
|
||||
|
@@ -36,6 +36,11 @@ module.exports = {
|
||||
}
|
||||
})
|
||||
},
|
||||
async quit() {
|
||||
for (const queueName in this.job) {
|
||||
await this.job[queueName].close()
|
||||
}
|
||||
},
|
||||
async clean() {
|
||||
return Promise.each(_.keys(WIKI.data.jobs), queueName => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@@ -19,5 +19,19 @@ module.exports = {
|
||||
WIKI.logger.error('Invalid Redis configuration!')
|
||||
process.exit(1)
|
||||
}
|
||||
},
|
||||
subscribe() {
|
||||
let red = this.init()
|
||||
red.on('message', (channel, msg) => {
|
||||
WIKI.events.emit(channel, msg)
|
||||
})
|
||||
red.subscribe('localization', (err, count) => {
|
||||
if (err) {
|
||||
WIKI.logger.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
WIKI.logger.info('Redis Subscriber connection: [ OK ]')
|
||||
})
|
||||
return red
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user