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.
试试这个:
pm2 start npm -- run littleAppleBot --
pm2 start npm -- run weatherWarnBot --
使用这个:-
pm2 start --name "Script Name" npm -- run <YOUR CUSTOM SCRIPT> --
pm2 start npm --name "你的应用名称" -- start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.