kernel.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* global WIKI */
  2. module.exports = {
  3. async init() {
  4. WIKI.logger.info('=======================================')
  5. WIKI.logger.info('= Wiki.js =============================')
  6. WIKI.logger.info('=======================================')
  7. WIKI.db = require('./db').init()
  8. WIKI.redis = require('./redis').init()
  9. WIKI.queue = require('./queue').init()
  10. await this.preBootMaster()
  11. this.bootMaster()
  12. },
  13. /**
  14. * Pre-Master Boot Sequence
  15. */
  16. async preBootMaster() {
  17. try {
  18. await WIKI.db.onReady
  19. await WIKI.configSvc.loadFromDb()
  20. await WIKI.queue.clean()
  21. } catch (err) {
  22. WIKI.logger.error(err)
  23. process.exit(1)
  24. }
  25. },
  26. /**
  27. * Boot Master Process
  28. */
  29. async bootMaster() {
  30. try {
  31. if (WIKI.config.setup) {
  32. WIKI.logger.info('Starting setup wizard...')
  33. require('../setup')()
  34. } else {
  35. await require('../master')()
  36. this.postBootMaster()
  37. }
  38. } catch (err) {
  39. WIKI.logger.error(err)
  40. process.exit(1)
  41. }
  42. },
  43. /**
  44. * Post-Master Boot Sequence
  45. */
  46. async postBootMaster() {
  47. await WIKI.auth.activateStrategies()
  48. await WIKI.queue.start()
  49. }
  50. }