index.js 1.34 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'),
14
  Error: require('./helpers/error'),
NGPixel's avatar
NGPixel committed
15 16
  configSvc: require('./modules/config'),
  kernel: require('./modules/kernel')
17 18
}
global.wiki = wiki
19

20 21
process.env.VIPS_WARNING = false

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

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

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

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

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

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

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

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

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

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

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