This commit is contained in:
syuilo 2018-07-28 17:57:24 +09:00
parent 1d6c0e1c6f
commit 01f60c829d

View file

@ -26,27 +26,28 @@ import { Config } from './config/types';
const clusterLog = debug('misskey:cluster'); const clusterLog = debug('misskey:cluster');
const ev = new Xev(); const ev = new Xev();
process.title = 'Misskey';
if (process.env.NODE_ENV != 'production') { if (process.env.NODE_ENV != 'production') {
process.env.DEBUG = 'misskey:*'; process.env.DEBUG = 'misskey:*';
} }
const pkg = require('../package.json'); const pkg = require('../package.json');
//#region Command line argument definitions
program program
.version(pkg.version) .version(pkg.version)
.option('--no-daemons', 'Disable daemon processes (for debbuging)') .option('--no-daemons', 'Disable daemon processes (for debbuging)')
.option('--disable-clustering', 'Disable clustering') .option('--disable-clustering', 'Disable clustering')
.parse(process.argv); .parse(process.argv);
//#endregion
// Start app
main(); main();
/** /**
* Init process * Init process
*/ */
function main() { function main() {
process.title = `Misskey (${ cluster.isMaster ? 'master' : 'worker' })`;
if (cluster.isMaster || program.disableClustering) { if (cluster.isMaster || program.disableClustering) {
masterMain(); masterMain();
@ -186,6 +187,8 @@ function spawnWorkers(limit: number) {
}); });
} }
//#region Events
// Listen new workers // Listen new workers
cluster.on('fork', worker => { cluster.on('fork', worker => {
clusterLog(`Process forked: [${worker.id}]`); clusterLog(`Process forked: [${worker.id}]`);
@ -216,3 +219,5 @@ process.on('uncaughtException', err => {
process.on('exit', code => { process.on('exit', code => {
Logger.info(`The process is going to exit with code ${code}`); Logger.info(`The process is going to exit with code ${code}`);
}); });
//#endregion