pyTelegramBotAPI:bot 在 Heroku 上大约 1 小时后停止 运行
pyTelegramBotAPI: bot stops running after about 1 hour on Heroku
我找不到解决办法。我在 python 中使用库 pyTelegramBotAPI 在 Heroku 上托管电报机器人,我的代码有效,但脚本 stop 运行ning 在新部署或通过控制台新执行 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)
用于在 Heroku 上部署的命令 git:
git add .
git commit -m "..."
git push heroku master
在 Heroku 上第一次用于 运行 机器人的命令(在登录 ecc. 之后):
heroku ps:scale web=1
有效,使用(控制台上的命令):
heroku ps:scale worker=1
我找不到解决办法。我在 python 中使用库 pyTelegramBotAPI 在 Heroku 上托管电报机器人,我的代码有效,但脚本 stop 运行ning 在新部署或通过控制台新执行 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)
用于在 Heroku 上部署的命令 git:
git add .
git commit -m "..."
git push heroku master
在 Heroku 上第一次用于 运行 机器人的命令(在登录 ecc. 之后):
heroku ps:scale web=1
有效,使用(控制台上的命令):
heroku ps:scale worker=1