diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-07-28 03:55:41 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-07-28 03:55:41 +0900 |
| commit | e4bf0392af81fc48bd2e5c1c321a543b347892c2 (patch) | |
| tree | e5ace1e28fec9011dafb4cfd4b59485b7a59831e /src | |
| parent | Merge pull request #2011 from syuilo/greenkeeper/webpack-4.16.3 (diff) | |
| download | misskey-e4bf0392af81fc48bd2e5c1c321a543b347892c2.tar.gz misskey-e4bf0392af81fc48bd2e5c1c321a543b347892c2.tar.bz2 misskey-e4bf0392af81fc48bd2e5c1c321a543b347892c2.zip | |
クラスタ数を制限するオプションを追加
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/types.ts | 2 | ||||
| -rw-r--r-- | src/index.ts | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/config/types.ts b/src/config/types.ts index a3d55e2843..f220e15822 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -92,6 +92,8 @@ export type Source = { }; google_maps_api_key: string; + + clusterLimit?: number; }; /** diff --git a/src/index.ts b/src/index.ts index 9c16c4d223..eae25762ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ async function masterMain() { Logger.succ('Misskey initialized'); - spawnWorkers(() => { + spawnWorkers(config.clusterLimit, () => { Logger.succ('All workers started'); Logger.info(`Now listening on port ${config.port} on ${config.url}`); }); @@ -137,14 +137,16 @@ async function init(): Promise<Config> { return config; } -function spawnWorkers(onComplete: Function) { +function spawnWorkers(limit: number, onComplete: Function) { // Count the machine's CPUs const cpuCount = os.cpus().length; - const progress = new ProgressBar(cpuCount, 'Starting workers'); + const count = limit || cpuCount; + + const progress = new ProgressBar(count, 'Starting workers'); // Create a worker for each CPU - for (let i = 0; i < cpuCount; i++) { + for (let i = 0; i < count; i++) { const worker = cluster.fork(); worker.on('message', message => { if (message === 'ready') { |