Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
index.js (keeper): Detect Bun runtime environment
Browse files Browse the repository at this point in the history
Signed-off-by: Yonle <yonle@lecturify.net>
  • Loading branch information
Yonle committed Jun 2, 2024
1 parent 4775641 commit 4612e89
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
process.title = "Bostr (keeper)";

const config = require(process.env.BOSTR_CONFIG_PATH || "./config");

if (typeof(Bun) === "object" && (config.clusters > 1)) {
console.log("You are running Bostr with Bun runtime.");
console.log("Clustering will not work, But worker thread will continue to work.");
return require("./http.js");
}

const cluster = require("cluster");
const fs = require("fs");
const os = require("os");
Expand All @@ -18,7 +25,7 @@ if (!process.env.NO_CLUSTERS && cluster.isPrimary) {
}

cluster.on('exit', (worker, code, signal) => {
console.log(`Worker ${worker.process.pid} died. Forking another one....`);
console.log(`Cluster process ${worker.process.pid} died. Forking another one....`);
cluster.fork();
});

Expand Down

0 comments on commit 4612e89

Please sign in to comment.