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.

67 lines
1.9 KiB

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