我找不到解决方案。我正在使用 Heroku 上的库 pyTelegramBotAPI 在python中托管电报机器人,我的代码有效,但脚本停止从新部署或通过控制台执行新命令后的1或2个小时后运行(或几分钟,我不知道确切的时间)。 问题出在哪里?感谢您的帮助。
Heroku上 logs 的示例:
2020-07-15T10:47:40.500384+00:00 app[api]: Starting process with command `python randobot.py` by user ________@gmail.com
2020-07-15T10:47:44.398310+00:00 heroku[run.1085]: State changed from starting to up
2020-07-15T10:47:44.455749+00:00 heroku[run.1085]: Awaiting client
2020-07-15T10:47:44.773283+00:00 heroku[run.1085]: Starting process with command `python\ randobot.py`
2020-07-15T10:47:50.709806+00:00 heroku[run.1085]: Client connection closed. Sending SIGHUP to all processes
2020-07-15T10:47:51.233462+00:00 heroku[run.1085]: Process exited with status 129
2020-07-15T10:47:51.270855+00:00 heroku[run.1085]: State changed from up to complete
Procfile。:
web: python randobot.py
代码 randobot.py :
import telebot
import time
import json
bot_token = "____________________________"
bot = telebot.TeleBot(token=bot_token)
...
... Some functions ...
...
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
logger.error(e)
time.sleep(15)
使用git在Heroku上进行部署的命令:
git add .
git commit -m "..."
git push heroku master
命令首次在Heroku上运行bot(登录ecc之后):
heroku ps:scale web=1
答案 0 :(得分:1)
它可以与(控制台上的命令)一起使用:
heroku ps:scale worker=1