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.7 KiB

  1. const Promise = require('bluebird')
  2. /* global wiki */
  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.lang = require('i18next')
  15. // ----------------------------------------
  16. // Localization Engine
  17. // ----------------------------------------
  18. const i18nBackend = require('i18next-node-fs-backend')
  19. wiki.lang.use(i18nBackend).init({
  20. load: 'languageOnly',
  21. ns: ['common', 'admin', 'auth', 'errors', 'git'],
  22. defaultNS: 'common',
  23. saveMissing: false,
  24. preload: [wiki.config.lang],
  25. lng: wiki.config.lang,
  26. fallbackLng: 'en',
  27. backend: {
  28. loadPath: path.join(wiki.SERVERPATH, 'locales/{{lng}}/{{ns}}.yml')
  29. }
  30. })
  31. // ----------------------------------------
  32. // Start Queues
  33. // ----------------------------------------
  34. const Bull = require('bull')
  35. const autoload = require('auto-load')
  36. let queues = autoload(path.join(wiki.SERVERPATH, 'queues'))
  37. for (let queueName in queues) {
  38. new Bull(queueName, {
  39. prefix: `q-${wiki.config.ha.nodeuid}`,
  40. redis: wiki.config.redis
  41. }).process(queues[queueName])
  42. }
  43. // ----------------------------------------
  44. // Shutdown gracefully
  45. // ----------------------------------------
  46. process.on('disconnect', () => {
  47. process.exit()
  48. })
  49. })