From b098499c67366f2ed4bd48df9eda07d5c80c42af Mon Sep 17 00:00:00 2001 From: Essem Date: Mon, 31 Oct 2022 12:49:19 -0500 Subject: [PATCH] oh god help --- events/ready.js | 2 ++ utils/pm2/ext.js | 42 +++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/events/ready.js b/events/ready.js index 4b2a81a..6574ac2 100644 --- a/events/ready.js +++ b/events/ready.js @@ -31,6 +31,8 @@ export default async (client) => { activityChanger(client); ready = true; + + process.send("ready"); logger.log("info", "Started esmBot."); }; \ No newline at end of file diff --git a/utils/pm2/ext.js b/utils/pm2/ext.js index e004304..7ace1fe 100644 --- a/utils/pm2/ext.js +++ b/utils/pm2/ext.js @@ -223,23 +223,27 @@ function calcShards(shards, procs) { } const shardArrays = calcShards(shardArray, procAmount); - pm2.start({ - name: "esmBot", - script: "app.js", - autorestart: true, - exp_backoff_restart_delay: 1000, - watch: false, - exec_mode: "cluster", - instances: shardArrays.length, - env: { - "SHARDS": JSON.stringify(shardArrays) - } - }, (err) => { - if (err) { - logger.error(`Failed to start esmBot: ${err}`); - process.exit(0); - } else { - logger.info("Started esmBot processes."); - } - }); + for (let i = 0; i < shardArrays.length; i++) { + pm2.start({ + name: "esmBot", + script: "app.js", + autorestart: true, + exp_backoff_restart_delay: 1000, + wait_ready: true, + listen_timeout: 60000, + watch: false, + exec_mode: "cluster", + instances: 1, + env: { + "SHARDS": JSON.stringify(shardArrays) + } + }, (err) => { + if (err) { + logger.error(`Failed to start esmBot process ${i}: ${err}`); + process.exit(0); + } else { + logger.info(`Started esmBot process ${i}.`); + } + }); + } })(); \ No newline at end of file