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.

69 lines
1.9 KiB

  1. 'use strict'
  2. /* global wiki */
  3. const Promise = require('bluebird')
  4. module.exports = Promise.join(
  5. wiki.db.onReady,
  6. wiki.configSvc.loadFromDb(['features', 'git', 'logging', 'site', 'uploads'])
  7. ).then(() => {
  8. const path = require('path')
  9. wiki.REPOPATH = path.resolve(wiki.ROOTPATH, wiki.config.paths.repo)
  10. wiki.DATAPATH = path.resolve(wiki.ROOTPATH, wiki.config.paths.data)
  11. wiki.UPLTEMPPATH = path.join(wiki.DATAPATH, 'temp-upload')
  12. // ----------------------------------------
  13. // Load global modules
  14. // ----------------------------------------
  15. // wiki.upl = require('./modules/uploads-agent').init()
  16. // wiki.git = require('./modules/git').init()
  17. // wiki.entries = require('./modules/entries').init()
  18. wiki.lang = require('i18next')
  19. wiki.mark = require('./modules/markdown')
  20. // ----------------------------------------
  21. // Localization Engine
  22. // ----------------------------------------
  23. const i18nBackend = require('i18next-node-fs-backend')
  24. wiki.lang.use(i18nBackend).init({
  25. load: 'languageOnly',
  26. ns: ['common', 'admin', 'auth', 'errors', 'git'],
  27. defaultNS: 'common',
  28. saveMissing: false,
  29. preload: [wiki.config.lang],
  30. lng: wiki.config.lang,
  31. fallbackLng: 'en',
  32. backend: {
  33. loadPath: path.join(wiki.SERVERPATH, 'locales/{{lng}}/{{ns}}.json')
  34. }
  35. })
  36. // ----------------------------------------
  37. // Start Queues
  38. // ----------------------------------------
  39. const Bull = require('bull')
  40. const autoload = require('auto-load')
  41. let queues = autoload(path.join(wiki.SERVERPATH, 'queues'))
  42. for (let queueName in queues) {
  43. new Bull(queueName, {
  44. prefix: `q-${wiki.config.ha.nodeuid}`,
  45. redis: wiki.config.redis
  46. }).process(queues[queueName])
  47. }
  48. // ----------------------------------------
  49. // Shutdown gracefully
  50. // ----------------------------------------
  51. process.on('disconnect', () => {
  52. wiki.logger.warn('Lost connection to Master. Exiting...')
  53. process.exit()
  54. })
  55. })