wikijs-fork/server/index.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-02-09 01:52:37 +00:00
'use strict'
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')
let wiki = {
IS_DEBUG: process.env.NODE_ENV === 'development',
ROOTPATH: process.cwd(),
SERVERPATH: path.join(process.cwd(), 'server')
}
global.wiki = wiki
2017-02-09 01:52:37 +00:00
process.env.VIPS_WARNING = false
// if (wiki.IS_DEBUG) {
2017-05-19 00:23:24 +00:00
// require('@glimpse/glimpse').init()
// }
let appconf = require('./modules/config')()
wiki.config = appconf.config
wiki.data = appconf.data
2017-03-29 00:19:01 +00:00
2016-08-17 00:56:55 +00:00
// ----------------------------------------
// Load Winston
2016-08-17 00:56:55 +00:00
// ----------------------------------------
2017-07-29 04:11:22 +00:00
wiki.logger = require('./modules/logger')()
2016-08-17 00:56:55 +00:00
// ----------------------------------------
2017-07-29 04:11:22 +00:00
// Start Cluster
// ----------------------------------------
2017-07-29 04:11:22 +00:00
const cluster = require('cluster')
const numCPUs = require('os').cpus().length
2017-07-29 04:11:22 +00:00
if (cluster.isMaster) {
wiki.logger.info('Wiki.js is initializing...')
2016-08-17 03:56:08 +00:00
2017-07-29 04:11:22 +00:00
require('./master')
2017-07-29 04:11:22 +00:00
for (let i = 0; i < numCPUs; i++) {
cluster.fork()
}
2017-07-29 04:11:22 +00:00
cluster.on('exit', (worker, code, signal) => {
wiki.logger.info(`Worker #${worker.id} died.`)
2017-05-19 00:23:24 +00:00
})
2017-07-29 04:11:22 +00:00
} else {
wiki.logger.info(`Background Worker #${cluster.worker.id} is starting...`)
// require('./worker')
}