Max Memory Restarting on Traditionally Sharded Bot

What do people here use for facilitating automatic max memory restarts with a traditionally sharded bot?
4 Replies
d.js toolkit
d.js toolkit14mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
dzlandis
dzlandis14mo ago
Doesn't work in this case, or at least I haven't figured out how to get it working, because PM2 only monitors a single process so the additional processes created from traditional sharding are not monitored :(
probablyraging
probablyraging14mo ago
I think what you want is pm2's cluster mode https://pm2.keymetrics.io/docs/usage/cluster-mode/
dzlandis
dzlandis14mo ago
Based on my understanding, PM2 cluster mode creates multiple processes in itself, similarly to how it would be done for a web application. So doing it with PM2's cluster mode would bypass the sharding manager entirely if I am understanding it correctly, which is unfortunately not a solution to my problem. I'm not quite sure I understand You mean I can use cluster mode with one process confusedBecel the problem is that the one process only uses like 100mb of RAM Whereas the other shards combined use a lot more RAM So I can't get an accurate RAM measurement to properly restart the whole bot. How can I see the allotted maximum? It's been crashing my whole program when I reach too much RAM. I believe my issue is more on the collective RAM usage of all my shards rather than individual shard usage unfortunately. And I believe passing in the max-old-size parameter would only apply to the main sharding process and not to each individual shard process.