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
commit7be11027d183caee6dbd930ad6ccf94cb67b7018 (patch)
tree50b56e562a54fdfdf1b9f7f59ed8ac293fdecf0f
parentMerge pull request #493 from RiversideRocks/patch-1 (diff)
downloadserver-7be11027d183caee6dbd930ad6ccf94cb67b7018.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) => {