2018-08-06 03:03:46 +00:00
|
|
|
const _ = require('lodash')
|
|
|
|
|
2018-03-05 20:49:36 +00:00
|
|
|
/* global WIKI */
|
2017-10-08 02:44:35 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2018-05-28 18:46:55 +00:00
|
|
|
async init() {
|
|
|
|
WIKI.logger.info('=======================================')
|
2018-08-06 03:03:46 +00:00
|
|
|
WIKI.logger.info(`= Wiki.js ${_.padEnd(WIKI.version + ' ', 29, '=')}`)
|
2018-05-28 18:46:55 +00:00
|
|
|
WIKI.logger.info('=======================================')
|
2017-10-08 02:44:35 +00:00
|
|
|
|
2018-07-30 02:23:33 +00:00
|
|
|
WIKI.models = require('./db').init()
|
2018-05-28 18:46:55 +00:00
|
|
|
WIKI.redis = require('./redis').init()
|
|
|
|
WIKI.queue = require('./queue').init()
|
2017-10-08 02:44:35 +00:00
|
|
|
|
2018-05-28 18:46:55 +00:00
|
|
|
await this.preBootMaster()
|
|
|
|
this.bootMaster()
|
2017-10-08 02:44:35 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Pre-Master Boot Sequence
|
|
|
|
*/
|
2018-05-28 18:46:55 +00:00
|
|
|
async preBootMaster() {
|
|
|
|
try {
|
2018-07-30 02:23:33 +00:00
|
|
|
await WIKI.models.onReady
|
2018-05-28 18:46:55 +00:00
|
|
|
await WIKI.configSvc.loadFromDb()
|
|
|
|
await WIKI.queue.clean()
|
|
|
|
} catch (err) {
|
|
|
|
WIKI.logger.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
2017-10-08 02:44:35 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Boot Master Process
|
|
|
|
*/
|
2018-05-28 18:46:55 +00:00
|
|
|
async bootMaster() {
|
|
|
|
try {
|
|
|
|
if (WIKI.config.setup) {
|
|
|
|
WIKI.logger.info('Starting setup wizard...')
|
2017-12-24 05:34:47 +00:00
|
|
|
require('../setup')()
|
2018-05-28 18:46:55 +00:00
|
|
|
} else {
|
|
|
|
await require('../master')()
|
|
|
|
this.postBootMaster()
|
2017-10-08 02:44:35 +00:00
|
|
|
}
|
2018-05-28 18:46:55 +00:00
|
|
|
} catch (err) {
|
2018-03-05 20:49:36 +00:00
|
|
|
WIKI.logger.error(err)
|
2017-10-08 02:44:35 +00:00
|
|
|
process.exit(1)
|
2018-05-28 18:46:55 +00:00
|
|
|
}
|
2017-10-08 02:44:35 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Post-Master Boot Sequence
|
|
|
|
*/
|
2017-12-24 05:34:47 +00:00
|
|
|
async postBootMaster() {
|
2018-08-04 21:27:55 +00:00
|
|
|
await WIKI.models.authentication.refreshStrategiesFromDisk()
|
2018-08-20 05:02:57 +00:00
|
|
|
await WIKI.models.editors.refreshEditorsFromDisk()
|
2018-09-01 19:15:44 +00:00
|
|
|
await WIKI.models.loggers.refreshLoggersFromDisk()
|
2018-08-27 02:38:08 +00:00
|
|
|
await WIKI.models.renderers.refreshRenderersFromDisk()
|
2018-09-01 19:15:44 +00:00
|
|
|
await WIKI.models.searchEngines.refreshSearchEnginesFromDisk()
|
2018-07-30 02:23:33 +00:00
|
|
|
await WIKI.models.storage.refreshTargetsFromDisk()
|
2018-08-06 03:03:46 +00:00
|
|
|
|
|
|
|
await WIKI.auth.activateStrategies()
|
2018-05-28 18:46:55 +00:00
|
|
|
await WIKI.queue.start()
|
2017-10-08 02:44:35 +00:00
|
|
|
}
|
|
|
|
}
|