12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // ===========================================
- // Wiki.js
- // Licensed under AGPLv3
- // ===========================================
- const path = require('path')
- const { nanoid } = require('nanoid')
- const { DateTime } = require('luxon')
- const { gte } = require('semver')
- // ----------------------------------------
- // Check Node.js version
- // ----------------------------------------
- if (gte(process.version, '21.0.0')) {
- console.error('You\'re using an unsupported Node.js version. Please read the requirements.')
- process.exit(1)
- }
- // ----------------------------------------
- // Init WIKI instance
- // ----------------------------------------
- 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()
- }
- global.WIKI = WIKI
- WIKI.configSvc.init()
- // ----------------------------------------
- // Init Logger
- // ----------------------------------------
- WIKI.logger = require('./core/logger').init('MASTER')
- // ----------------------------------------
- // Start Kernel
- // ----------------------------------------
- WIKI.kernel.init()
- // ----------------------------------------
- // Register exit handler
- // ----------------------------------------
- process.on('SIGTERM', () => {
- WIKI.kernel.shutdown()
- })
- process.on('SIGINT', () => {
- WIKI.kernel.shutdown()
- })
- process.on('message', (msg) => {
- if (msg === 'shutdown') {
- WIKI.kernel.shutdown()
- }
- })
|