クラスタ数を制限するオプションを追加
This commit is contained in:
parent
5c6f24dc39
commit
e4bf0392af
3 changed files with 11 additions and 4 deletions
|
@ -131,3 +131,6 @@ drive:
|
||||||
# Ghost account is an account used for the purpose of delegating
|
# Ghost account is an account used for the purpose of delegating
|
||||||
# followers when putting users in the list.
|
# followers when putting users in the list.
|
||||||
# ghost: user-id-of-your-ghost-account
|
# ghost: user-id-of-your-ghost-account
|
||||||
|
|
||||||
|
# Clustering
|
||||||
|
# clusterLimit: 1
|
||||||
|
|
|
@ -92,6 +92,8 @@ export type Source = {
|
||||||
};
|
};
|
||||||
|
|
||||||
google_maps_api_key: string;
|
google_maps_api_key: string;
|
||||||
|
|
||||||
|
clusterLimit?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -66,7 +66,7 @@ async function masterMain() {
|
||||||
|
|
||||||
Logger.succ('Misskey initialized');
|
Logger.succ('Misskey initialized');
|
||||||
|
|
||||||
spawnWorkers(() => {
|
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}`);
|
||||||
});
|
});
|
||||||
|
@ -137,14 +137,16 @@ async function init(): Promise<Config> {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnWorkers(onComplete: Function) {
|
function spawnWorkers(limit: number, onComplete: Function) {
|
||||||
// Count the machine's CPUs
|
// Count the machine's CPUs
|
||||||
const cpuCount = os.cpus().length;
|
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
|
// Create a worker for each CPU
|
||||||
for (let i = 0; i < cpuCount; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const worker = cluster.fork();
|
const worker = cluster.fork();
|
||||||
worker.on('message', message => {
|
worker.on('message', message => {
|
||||||
if (message === 'ready') {
|
if (message === 'ready') {
|
||||||
|
|
Loading…
Reference in a new issue