wikijs-fork/server/index.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-08-17 00:56:55 +00:00
// ===========================================
// Wiki.js
2016-08-17 00:56:55 +00:00
// Licensed under AGPLv3
// ===========================================
const path = require('path')
2020-04-20 00:26:26 +00:00
const { nanoid } = require('nanoid')
const { DateTime } = require('luxon')
2017-07-29 21:33:08 +00:00
let WIKI = {
IS_DEBUG: process.env.NODE_ENV === 'development',
2018-05-28 18:46:55 +00:00
IS_MASTER: true,
ROOTPATH: process.cwd(),
INSTANCE_ID: nanoid(10),
2017-07-29 21:33:08 +00:00
SERVERPATH: path.join(process.cwd(), 'server'),
2018-01-10 01:41:53 +00:00
Error: require('./helpers/error'),
configSvc: require('./core/config'),
kernel: require('./core/kernel'),
startedAt: DateTime.utc()
}
global.WIKI = WIKI
WIKI.configSvc.init()
2017-07-29 21:33:08 +00:00
// ----------------------------------------
// Init Logger
// ----------------------------------------
WIKI.logger = require('./core/logger').init('MASTER')
2017-03-29 00:19:01 +00:00
// ----------------------------------------
2017-10-08 02:44:35 +00:00
// Start Kernel
// ----------------------------------------
WIKI.kernel.init()
// ----------------------------------------
// Register exit handler
// ----------------------------------------
process.on('SIGINT', () => {
WIKI.kernel.shutdown()
})
process.on('message', (msg) => {
if (msg === 'shutdown') {
WIKI.kernel.shutdown()
}
})