summary refs log tree commit diff
path: root/src/bundle/start.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/bundle/start.ts')
-rw-r--r--src/bundle/start.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/bundle/start.ts b/src/bundle/start.ts
index 10fb7c36..8da3cc20 100644
--- a/src/bundle/start.ts
+++ b/src/bundle/start.ts
@@ -29,14 +29,15 @@ import { execSync } from "child_process";
 
 const cores = process.env.THREADS ? parseInt(process.env.THREADS) : 1;
 
-if (cluster.isPrimary) {
-	function getCommitOrFail() {
-		try {
-			return execSync("git rev-parse HEAD").toString().trim();
-		} catch (e) {
-			return null;
-		}
+function getCommitOrFail() {
+	try {
+		return execSync("git rev-parse HEAD").toString().trim();
+	} catch (e) {
+		return null;
 	}
+}
+
+if (cluster.isPrimary) {
 	const commit = getCommitOrFail();
 
 	console.log(
@@ -81,14 +82,14 @@ Cores: ${cyan(os.cpus().length)} (Using ${cores} thread(s).)
 		// Fork workers.
 		for (let i = 0; i < cores; i++) {
 			// Delay each worker start if using sqlite database to prevent locking it
-			let delay = process.env.DATABASE?.includes("://") ? 0 : i * 1000;
+			const delay = process.env.DATABASE?.includes("://") ? 0 : i * 1000;
 			setTimeout(() => {
 				cluster.fork();
 				console.log(`[Process] worker ${cyan(i)} started.`);
 			}, delay);
 		}
 
-		cluster.on("message", (sender: Worker, message: any) => {
+		cluster.on("message", (sender: Worker, message) => {
 			for (const id in cluster.workers) {
 				const worker = cluster.workers[id];
 				if (worker === sender || !worker) continue;
@@ -96,7 +97,7 @@ Cores: ${cyan(os.cpus().length)} (Using ${cores} thread(s).)
 			}
 		});
 
-		cluster.on("exit", (worker: any, code: any, signal: any) => {
+		cluster.on("exit", (worker) => {
 			console.log(
 				`[Worker] ${red(
 					`died with PID: ${worker.process.pid} , restarting ...`,