You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. const _ = require('lodash')
  2. /* global WIKI */
  3. module.exports = {
  4. async init() {
  5. WIKI.logger.info('=======================================')
  6. WIKI.logger.info(`= Wiki.js ${_.padEnd(WIKI.version + ' ', 29, '=')}`)
  7. WIKI.logger.info('=======================================')
  8. WIKI.models = require('./db').init()
  9. WIKI.redis = require('./redis').init()
  10. WIKI.queue = require('./queue').init()
  11. await this.preBootMaster()
  12. this.bootMaster()
  13. },
  14. /**
  15. * Pre-Master Boot Sequence
  16. */
  17. async preBootMaster() {
  18. try {
  19. await WIKI.models.onReady
  20. await WIKI.configSvc.loadFromDb()
  21. await WIKI.queue.clean()
  22. } catch (err) {
  23. WIKI.logger.error(err)
  24. process.exit(1)
  25. }
  26. },
  27. /**
  28. * Boot Master Process
  29. */
  30. async bootMaster() {
  31. try {
  32. if (WIKI.config.setup) {
  33. WIKI.logger.info('Starting setup wizard...')
  34. require('../setup')()
  35. } else {
  36. await require('../master')()
  37. this.postBootMaster()
  38. }
  39. } catch (err) {
  40. WIKI.logger.error(err)
  41. process.exit(1)
  42. }
  43. },
  44. /**
  45. * Post-Master Boot Sequence
  46. */
  47. async postBootMaster() {
  48. await WIKI.models.authentication.refreshStrategiesFromDisk()
  49. await WIKI.models.editors.refreshEditorsFromDisk()
  50. await WIKI.models.loggers.refreshLoggersFromDisk()
  51. await WIKI.models.renderers.refreshRenderersFromDisk()
  52. await WIKI.models.searchEngines.refreshSearchEnginesFromDisk()
  53. await WIKI.models.storage.refreshTargetsFromDisk()
  54. await WIKI.auth.activateStrategies()
  55. await WIKI.queue.start()
  56. }
  57. }