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.

48 lines
1.1 KiB

  1. // ===========================================
  2. // Wiki.js
  3. // Licensed under AGPLv3
  4. // ===========================================
  5. const path = require('path')
  6. const { nanoid } = require('nanoid')
  7. const { DateTime } = require('luxon')
  8. let WIKI = {
  9. IS_DEBUG: process.env.NODE_ENV === 'development',
  10. IS_MASTER: true,
  11. ROOTPATH: process.cwd(),
  12. INSTANCE_ID: nanoid(10),
  13. SERVERPATH: path.join(process.cwd(), 'server'),
  14. Error: require('./helpers/error'),
  15. configSvc: require('./core/config'),
  16. kernel: require('./core/kernel'),
  17. startedAt: DateTime.utc()
  18. }
  19. global.WIKI = WIKI
  20. WIKI.configSvc.init()
  21. // ----------------------------------------
  22. // Init Logger
  23. // ----------------------------------------
  24. WIKI.logger = require('./core/logger').init('MASTER')
  25. // ----------------------------------------
  26. // Start Kernel
  27. // ----------------------------------------
  28. WIKI.kernel.init()
  29. // ----------------------------------------
  30. // Register exit handler
  31. // ----------------------------------------
  32. process.on('SIGINT', () => {
  33. WIKI.kernel.shutdown()
  34. })
  35. process.on('message', (msg) => {
  36. if (msg === 'shutdown') {
  37. WIKI.kernel.shutdown()
  38. }
  39. })