2017-07-29 04:11:22 +00:00
|
|
|
/* global wiki */
|
2016-09-01 02:45:28 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
const Promise = require('bluebird')
|
2017-07-29 21:33:08 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
module.exports = Promise.join(
|
|
|
|
wiki.db.onReady,
|
|
|
|
wiki.configSvc.loadFromDb(['features', 'git', 'logging', 'site', 'uploads'])
|
|
|
|
).then(() => {
|
|
|
|
const path = require('path')
|
2016-09-05 04:39:59 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
wiki.REPOPATH = path.resolve(wiki.ROOTPATH, wiki.config.paths.repo)
|
|
|
|
wiki.DATAPATH = path.resolve(wiki.ROOTPATH, wiki.config.paths.data)
|
|
|
|
wiki.UPLTEMPPATH = path.join(wiki.DATAPATH, 'temp-upload')
|
2016-10-15 03:31:15 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
// ----------------------------------------
|
|
|
|
// Load global modules
|
|
|
|
// ----------------------------------------
|
2016-09-01 02:45:28 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
// wiki.upl = require('./modules/uploads-agent').init()
|
|
|
|
// wiki.git = require('./modules/git').init()
|
|
|
|
// wiki.entries = require('./modules/entries').init()
|
|
|
|
wiki.lang = require('i18next')
|
|
|
|
wiki.mark = require('./modules/markdown')
|
2016-09-25 04:08:49 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
// ----------------------------------------
|
|
|
|
// Localization Engine
|
|
|
|
// ----------------------------------------
|
2017-05-04 02:10:12 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
const i18nBackend = require('i18next-node-fs-backend')
|
|
|
|
wiki.lang.use(i18nBackend).init({
|
|
|
|
load: 'languageOnly',
|
|
|
|
ns: ['common', 'admin', 'auth', 'errors', 'git'],
|
|
|
|
defaultNS: 'common',
|
|
|
|
saveMissing: false,
|
|
|
|
preload: [wiki.config.lang],
|
|
|
|
lng: wiki.config.lang,
|
|
|
|
fallbackLng: 'en',
|
|
|
|
backend: {
|
|
|
|
loadPath: path.join(wiki.SERVERPATH, 'locales/{{lng}}/{{ns}}.json')
|
|
|
|
}
|
|
|
|
})
|
2017-05-04 02:10:12 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
// ----------------------------------------
|
|
|
|
// Start Queues
|
|
|
|
// ----------------------------------------
|
2016-09-01 02:45:28 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
const Bull = require('bull')
|
|
|
|
const autoload = require('auto-load')
|
2017-02-09 01:52:37 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
let queues = autoload(path.join(wiki.SERVERPATH, 'queues'))
|
2017-02-09 01:52:37 +00:00
|
|
|
|
2017-07-29 21:33:08 +00:00
|
|
|
for (let queueName in queues) {
|
2017-08-03 03:47:11 +00:00
|
|
|
new Bull(queueName, {
|
|
|
|
prefix: `q-${wiki.config.ha.nodeuid}`,
|
|
|
|
redis: wiki.config.redis
|
|
|
|
}).process(queues[queueName])
|
2017-07-29 21:33:08 +00:00
|
|
|
}
|
2016-09-05 04:39:59 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
// ----------------------------------------
|
|
|
|
// Shutdown gracefully
|
|
|
|
// ----------------------------------------
|
2016-09-01 02:45:28 +00:00
|
|
|
|
2017-08-03 03:47:11 +00:00
|
|
|
process.on('disconnect', () => {
|
|
|
|
wiki.logger.warn('Lost connection to Master. Exiting...')
|
|
|
|
process.exit()
|
|
|
|
})
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|