mirror of
https://github.com/Yonle/bostr.git
synced 2025-11-18 01:46:46 +01:00
allow for setting number of clusters via config.js
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
@@ -93,6 +93,7 @@ function terminate_sess(id) {
|
|||||||
socks.forEach(sock => {
|
socks.forEach(sock => {
|
||||||
if (sock.id !== id) return;
|
if (sock.id !== id) return;
|
||||||
sock.terminate();
|
sock.terminate();
|
||||||
|
socks.delete(sock);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ module.exports = {
|
|||||||
// 2 -> Accurate, But every clients will connects to numbers of <relays>
|
// 2 -> Accurate, But every clients will connects to numbers of <relays>
|
||||||
mode: 1,
|
mode: 1,
|
||||||
|
|
||||||
|
clusters: 1,
|
||||||
|
|
||||||
// Server information.
|
// Server information.
|
||||||
// Only for when nostr client requesting server information.
|
// Only for when nostr client requesting server information.
|
||||||
server_meta: {
|
server_meta: {
|
||||||
|
|||||||
3
index.js
3
index.js
@@ -1,3 +1,4 @@
|
|||||||
|
const config = require("./config");
|
||||||
const cluster = require("cluster");
|
const cluster = require("cluster");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
@@ -7,7 +8,7 @@ if (!process.env.NO_CLUSTERS && cluster.isPrimary) {
|
|||||||
fs.rmSync(".temporary.db");
|
fs.rmSync(".temporary.db");
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
const numClusters = process.env.CLUSTERS || (os.availableParallelism ? os.availableParallelism() : (os.cpus().length || 2))
|
const numClusters = process.env.CLUSTERS || config.clusters || (os.availableParallelism ? os.availableParallelism() : (os.cpus().length || 2))
|
||||||
|
|
||||||
console.log(`Primary ${process.pid} is running. Will fork ${numClusters} clusters.`);
|
console.log(`Primary ${process.pid} is running. Will fork ${numClusters} clusters.`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user