From 21f3047ad4e5b1f81ab6b9aaa58eab4381e985fc Mon Sep 17 00:00:00 2001 From: Essem Date: Mon, 31 Oct 2022 13:09:21 -0500 Subject: [PATCH] please work god dammit --- utils/pm2/ext.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/pm2/ext.js b/utils/pm2/ext.js index 7ace1fe..1f717cd 100644 --- a/utils/pm2/ext.js +++ b/utils/pm2/ext.js @@ -224,8 +224,14 @@ function calcShards(shards, procs) { const shardArrays = calcShards(shardArray, procAmount); for (let i = 0; i < shardArrays.length; i++) { + await awaitStart(i, shardArrays); + } +})(); + +function awaitStart(i, shardArrays) { + return new Promise((resolve) => { pm2.start({ - name: "esmBot", + name: `esmBot-${i}`, script: "app.js", autorestart: true, exp_backoff_restart_delay: 1000, @@ -243,7 +249,8 @@ function calcShards(shards, procs) { process.exit(0); } else { logger.info(`Started esmBot process ${i}.`); + resolve(); } }); - } -})(); \ No newline at end of file + }); +} \ No newline at end of file