mirror of https://github.com/requarks/wiki
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.
59 lines
1.3 KiB
59 lines
1.3 KiB
// ===========================================
|
|
// Wiki.js
|
|
// Licensed under AGPLv3
|
|
// ===========================================
|
|
|
|
const path = require('path')
|
|
const { nanoid } = require('nanoid')
|
|
const { DateTime } = require('luxon')
|
|
const semver = require('semver')
|
|
|
|
if (!semver.satisfies(process.version, '>=18')) {
|
|
console.error('ERROR: Node.js 18.x or later required!')
|
|
process.exit(1)
|
|
}
|
|
|
|
let WIKI = {
|
|
IS_DEBUG: process.env.NODE_ENV === 'development',
|
|
IS_MASTER: true,
|
|
ROOTPATH: process.cwd(),
|
|
INSTANCE_ID: nanoid(10),
|
|
SERVERPATH: path.join(process.cwd(), 'server'),
|
|
Error: require('./helpers/error'),
|
|
configSvc: require('./core/config'),
|
|
kernel: require('./core/kernel'),
|
|
startedAt: DateTime.utc(),
|
|
storage: {
|
|
defs: [],
|
|
modules: []
|
|
}
|
|
}
|
|
global.WIKI = WIKI
|
|
|
|
WIKI.configSvc.init()
|
|
|
|
// ----------------------------------------
|
|
// Init Logger
|
|
// ----------------------------------------
|
|
|
|
WIKI.logger = require('./core/logger').init()
|
|
|
|
// ----------------------------------------
|
|
// Start Kernel
|
|
// ----------------------------------------
|
|
|
|
WIKI.kernel.init()
|
|
|
|
// ----------------------------------------
|
|
// Register exit handler
|
|
// ----------------------------------------
|
|
|
|
process.on('SIGINT', () => {
|
|
WIKI.kernel.shutdown()
|
|
})
|
|
process.on('message', (msg) => {
|
|
if (msg === 'shutdown') {
|
|
WIKI.kernel.shutdown()
|
|
}
|
|
})
|