PM2 Configuration File for Sharded bot

How can I create an auto restart config in PM2 for Sharded bot?

Will this work?
module.exports = {
  apps: [
    {
      name: 'bot',
      script: './index.js',
      args: '--color',
      node_args: '--max_old_space_size=12000',
      max_memory_restart: '10G',
    },
  ],
};

The problem is when the main process crashes for some reason, The shards keeps running independently.
Was this page helpful?