I am currently developing several Telegram bots but I want to keep all of them in the same git repository. The issue is that on the other hand, I want to run them as separate processes.
Since I'm using the Telegraf framework, to run a bot it goes such as: micro-bot src/bot-one/bot.js
The problem comes when doing this with PM2. I've been able to run one of the bots with the npm start
script like this:
pm2 start --name "WeatherBot" npm -- start -- -t <
TOKEN>
But I'd like to be able to create custom scripts like this:
"main": "src/weatherWarnBot/bot.js",
"scripts": {
"start": "micro-bot",
"littleAppleBot": "micro-bot src/littleAppleBot/bot.js",
"weatherWarnBot": "micro-bot src/weatherWarnBot/bot.js"
}
But, how would the PM2 command be to run each of the two custom scripts? I was thinking of having the bot tokens set as enviroment variables of the system, for simplification.