Skip to content

Commit

Permalink
chore(bot): name processes by shard id
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Apr 14, 2024
1 parent 12292fa commit add27b3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apps/bot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ export async function connect() {
await prisma.$connect();
influxCron.start();
client.bot.editStatus('online', client.config.status);

let botName = 'Craig';
if (process.env.pm_pid_path && process.env.pm_id) {
try {
const pm2Name = process.env.pm_pid_path
.split('\\')
.reverse()[0]
.split('/')
.reverse()[0]
.slice(0, -`-${process.env.pm_id}.pid`.length)
.split('-')
.join(' ');
botName = `${pm2Name} [${process.env.pm_id}]`;
} catch (e) {}
}

process.title = `${botName} - ${
process.env.SHARD_ID ? `Shard ${process.env.SHARD_ID}/${process.env.SHARD_COUNT}` : `${client.bot.shards.size} shard(s)`
}`;
}

export async function disconnect() {
Expand Down

0 comments on commit add27b3

Please sign in to comment.