いくつかのコマンドラインオプションを追加するなど
This commit is contained in:
parent
23c32f1211
commit
fb74f1d72b
@ -90,6 +90,7 @@
|
|||||||
"bootstrap-vue": "2.0.0-rc.11",
|
"bootstrap-vue": "2.0.0-rc.11",
|
||||||
"cafy": "11.3.0",
|
"cafy": "11.3.0",
|
||||||
"chalk": "2.4.1",
|
"chalk": "2.4.1",
|
||||||
|
"commander": "2.16.0",
|
||||||
"crc-32": "1.2.0",
|
"crc-32": "1.2.0",
|
||||||
"css-loader": "1.0.0",
|
"css-loader": "1.0.0",
|
||||||
"dateformat": "3.0.3",
|
"dateformat": "3.0.3",
|
||||||
|
45
src/index.ts
45
src/index.ts
@ -11,6 +11,7 @@ import chalk from 'chalk';
|
|||||||
import * as portscanner from 'portscanner';
|
import * as portscanner from 'portscanner';
|
||||||
import isRoot = require('is-root');
|
import isRoot = require('is-root');
|
||||||
import Xev from 'xev';
|
import Xev from 'xev';
|
||||||
|
import * as program from 'commander';
|
||||||
|
|
||||||
import Logger from './misc/logger';
|
import Logger from './misc/logger';
|
||||||
import ProgressBar from './misc/cli/progressbar';
|
import ProgressBar from './misc/cli/progressbar';
|
||||||
@ -31,6 +32,14 @@ if (process.env.NODE_ENV != 'production') {
|
|||||||
process.env.DEBUG = 'misskey:*';
|
process.env.DEBUG = 'misskey:*';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pkg = require('../package.json');
|
||||||
|
|
||||||
|
program
|
||||||
|
.version(pkg.version)
|
||||||
|
.option('--no-daemons', 'Disable daemon processes (for debbuging)')
|
||||||
|
.option('--disable-clustering', 'Disable clustering')
|
||||||
|
.parse(process.argv);
|
||||||
|
|
||||||
// Start app
|
// Start app
|
||||||
main();
|
main();
|
||||||
|
|
||||||
@ -38,13 +47,20 @@ main();
|
|||||||
* Init process
|
* Init process
|
||||||
*/
|
*/
|
||||||
function main() {
|
function main() {
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster || program.disableClustering) {
|
||||||
masterMain();
|
masterMain();
|
||||||
|
|
||||||
|
if (cluster.isMaster) {
|
||||||
ev.mount();
|
ev.mount();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!program.noDaemons) {
|
||||||
serverStats();
|
serverStats();
|
||||||
notesStats();
|
notesStats();
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cluster.isWorker || program.disableClustering) {
|
||||||
workerMain();
|
workerMain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,10 +82,12 @@ async function masterMain() {
|
|||||||
|
|
||||||
Logger.succ('Misskey initialized');
|
Logger.succ('Misskey initialized');
|
||||||
|
|
||||||
spawnWorkers(config.clusterLimit, () => {
|
if (!program.disableClustering) {
|
||||||
|
await spawnWorkers(config.clusterLimit);
|
||||||
Logger.succ('All workers started');
|
Logger.succ('All workers started');
|
||||||
|
}
|
||||||
|
|
||||||
Logger.info(`Now listening on port ${config.port} on ${config.url}`);
|
Logger.info(`Now listening on port ${config.port} on ${config.url}`);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,9 +97,11 @@ async function workerMain() {
|
|||||||
// start server
|
// start server
|
||||||
await require('./server').default();
|
await require('./server').default();
|
||||||
|
|
||||||
|
if (cluster.isWorker) {
|
||||||
// Send a 'ready' message to parent process
|
// Send a 'ready' message to parent process
|
||||||
process.send('ready');
|
process.send('ready');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init app
|
* Init app
|
||||||
@ -124,20 +144,24 @@ async function init(): Promise<Config> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to connect to MongoDB
|
// Try to connect to MongoDB
|
||||||
|
checkMongoDb(config);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkMongoDb(config: Config) {
|
||||||
const mongoDBLogger = new Logger('MongoDB');
|
const mongoDBLogger = new Logger('MongoDB');
|
||||||
mongoDBLogger.info(`Host: ${config.mongodb.host}`);
|
mongoDBLogger.info(`Host: ${config.mongodb.host}`);
|
||||||
mongoDBLogger.info(`Port: ${config.mongodb.port}`);
|
mongoDBLogger.info(`Port: ${config.mongodb.port}`);
|
||||||
mongoDBLogger.info(`DB: ${config.mongodb.db}`);
|
mongoDBLogger.info(`DB: ${config.mongodb.db}`);
|
||||||
if (config.mongodb.user) mongoDBLogger.info(`User: ${config.mongodb.user}`);
|
if (config.mongodb.user) mongoDBLogger.info(`User: ${config.mongodb.user}`);
|
||||||
if (config.mongodb.pass) mongoDBLogger.info(`Pass: ****`);
|
if (config.mongodb.pass) mongoDBLogger.info(`Pass: ****`);
|
||||||
const db = require('./db/mongodb').default;
|
require('./db/mongodb');
|
||||||
mongoDBLogger.succ('Connectivity confirmed');
|
mongoDBLogger.succ('Connectivity confirmed');
|
||||||
db.close();
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnWorkers(limit: number, onComplete: Function) {
|
function spawnWorkers(limit: number) {
|
||||||
|
return new Promise(res => {
|
||||||
// Count the machine's CPUs
|
// Count the machine's CPUs
|
||||||
const cpuCount = os.cpus().length;
|
const cpuCount = os.cpus().length;
|
||||||
|
|
||||||
@ -157,7 +181,8 @@ function spawnWorkers(limit: number, onComplete: Function) {
|
|||||||
|
|
||||||
// On all workers started
|
// On all workers started
|
||||||
progress.on('complete', () => {
|
progress.on('complete', () => {
|
||||||
onComplete();
|
res();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user