首页 > 解决方案 > 部署在 heroku 上的 Discord 机器人在启动后崩溃

问题描述

我为不和谐频道制作了一个聊天机器人,如果我在本地机器上运行它,它运行良好。当我试图在heroku上部署它时,它并没有出现在不和谐的在线状态,然后它就崩溃了。

我试图找到“状态 255”的解释(见日志),但这只是意味着“错误”?

启动后,机器人发出一个“获取”请求(我试图让我的机器人异步并添加了一个异步任务),我认为问题出在这个问题上。

def is_xur_here() -> bool:
    """Function checking Xur and returns True/False."""
    xur_url = 'https://paracausal.science/xur/current.json'

    response = requests.get(xur_url, headers=HEADERS)
    data = response.json()

    search_result = False if data is None else True

    return search_result

此外,我在 heroku 上部署了另一个机器人,它运行良好。我认为问题出在请求上,所以我尝试制作另一个 Procfile (web),但 heroku 报告它没有看到任何 web 进程。

档案:

worker: python bot_main.py

要求.txt:

aiohttp==3.6.3
async-timeout==3.0.1
attrs==20.3.0
beautifulsoup4==4.9.3
certifi==2020.11.8
chardet==3.0.4
discord==1.0.1
discord.py==1.5.1
fuzzywuzzy==0.18.0
idna==2.10
lxml==4.6.2
multidict==4.7.6
python-dotenv==0.15.0
python-Levenshtein==0.12.0
requests==2.25.0
soupsieve==2.0.1
urllib3==1.26.2
yarl==1.5.1

来自heroku的日志:

2021-01-25T09:29:46.725997+00:00 heroku[worker.1]: State changed from crashed to starting
2021-01-25T09:29:50.461679+00:00 heroku[worker.1]: Starting process with command `python bot_main.py`
2021-01-25T09:29:51.062255+00:00 heroku[worker.1]: State changed from starting to up
2021-01-25T09:29:54.253986+00:00 heroku[worker.1]: Process exited with status 255

如果有人想查看它,这是为了方便起见的机器人代码。我真的不知道还有什么可能需要得到答案,我将不胜感激任何方向。

标签: python-3.xherokudeploymentdiscord.pypython-asyncio

解决方案


推荐阅读