From 7be11027d183caee6dbd930ad6ccf94cb67b7018 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:42:00 +0200 Subject: :bug: delay worker thread start --- bundle/src/start.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bundle') 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) => { -- cgit 1.4.1