🐛 delay worker thread start
This commit is contained in:
parent
90ece05efc
commit
7f51408e0e
@ -61,8 +61,12 @@ Current commit: ${
|
|||||||
|
|
||||||
// Fork workers.
|
// Fork workers.
|
||||||
for (let i = 0; i < cores; i++) {
|
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;
|
||||||
|
setTimeout(() => {
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
console.log(`[Process] worker ${i} started.`);
|
console.log(`[Process] worker ${i} started.`);
|
||||||
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster.on("message", (sender: Worker, message: any) => {
|
cluster.on("message", (sender: Worker, message: any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user