summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-22 23:42:00 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-22 23:42:00 +0200
commit7f51408e0e09a45fc672017aacf50361d7b4145a (patch)
treec8c455519a8ea432dd438f053013e980d04788ec
parentMerge pull request #493 from RiversideRocks/patch-1 (diff)
downloadserver-7f51408e0e09a45fc672017aacf50361d7b4145a.tar.xz
:bug: delay worker thread start
-rw-r--r--bundle/src/start.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/bundle/src/start.ts b/bundle/src/start.ts
index ee914b8b..4445fde6 100644
--- a/bundle/src/start.ts
+++ b/bundle/src/start.ts
@@ -61,8 +61,12 @@ Current commit: ${
 
 		// Fork workers.
 		for (let i = 0; i < cores; i++) {
-			cluster.fork();
-			console.log(`[Process] worker ${i} started.`);
+			// Delay each worker start if using sqlite database to prevent locking it
+			let delay = process.env.DATABASE?.includes("://") ? 0 : i * 1000;
+			setTimeout(() => {
+				cluster.fork();
+				console.log(`[Process] worker ${i} started.`);
+			}, delay);
 		}
 
 		cluster.on("message", (sender: Worker, message: any) => {