1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-24 19:32:46 +01:00

🐛 delay worker thread start

This commit is contained in:
Flam3rboy 2021-10-22 23:42:00 +02:00
parent 90ece05efc
commit 7f51408e0e

View File

@ -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) => {