index.js 1.31 KB
Newer Older
NGPixel's avatar
NGPixel committed
1
// ===========================================
2
// Wiki.js
NGPixel's avatar
NGPixel committed
3 4 5
// Licensed under AGPLv3
// ===========================================

6
const path = require('path')
7 8
const cluster = require('cluster')

9 10
let wiki = {
  IS_DEBUG: process.env.NODE_ENV === 'development',
11
  IS_MASTER: cluster.isMaster,
12
  ROOTPATH: process.cwd(),
13
  SERVERPATH: path.join(process.cwd(), 'server'),
NGPixel's avatar
NGPixel committed
14 15
  configSvc: require('./modules/config'),
  kernel: require('./modules/kernel')
16 17
}
global.wiki = wiki
18

19 20
process.env.VIPS_WARNING = false

21
// if (wiki.IS_DEBUG) {
22 23
//   require('@glimpse/glimpse').init()
// }
24

25 26 27 28 29 30 31
wiki.configSvc.init()

// ----------------------------------------
// Init Logger
// ----------------------------------------

wiki.logger = require('./modules/logger').init()
32

NGPixel's avatar
NGPixel committed
33 34 35 36 37 38
// ----------------------------------------
// Init Telemetry
// ----------------------------------------

wiki.telemetry = require('./modules/telemetry').init()

39 40 41 42 43 44 45
process.on('unhandledRejection', (err) => {
  wiki.telemetry.sendError(err)
})
process.on('uncaughtException', (err) => {
  wiki.telemetry.sendError(err)
})

NGPixel's avatar
NGPixel committed
46
// ----------------------------------------
47
// Init DB
NGPixel's avatar
NGPixel committed
48 49
// ----------------------------------------

50
wiki.db = require('./modules/db').init()
NGPixel's avatar
NGPixel committed
51

52
// ----------------------------------------
NGPixel's avatar
NGPixel committed
53
// Start Kernel
54
// ----------------------------------------
55

NGPixel's avatar
NGPixel committed
56
wiki.kernel.init()