我最近成功部署了一个 Heroku 应用程序(查看下面的日志了解详细信息),但是当我尝试通过浏览器访问我的应用程序时,它回传An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail
. 此外,我的应用程序适用于 Discord.Py 机器人,而该机器人并未像应有的那样在线。
日志:
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> No Python version was specified. Using the same version as the last build: python-3.9.9
To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
-----> Requirements file has been changed, clearing cached dependencies
-----> Installing python-3.9.9
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting discord.py==1.6.0
Downloading discord.py-1.6.0-py3-none-any.whl (779 kB)
Collecting Flask==2.0.2
Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
Collecting dnspython==1.16.0
Downloading dnspython-1.16.0-py2.py3-none-any.whl (188 kB)
Collecting PyNaCl==1.3.0
Downloading PyNaCl-1.3.0-cp34-abi3-manylinux1_x86_64.whl (759 kB)
Collecting async-timeout==3.0.1
Downloading async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting aiohttp<3.8.0,>=3.6.0
Downloading aiohttp-3.7.4.post0-cp39-cp39-manylinux2014_x86_64.whl (1.4 MB)
Collecting Jinja2>=3.0
Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
Collecting itsdangerous>=2.0
Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Collecting Werkzeug>=2.0
Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
Collecting click>=7.1.2
Downloading click-8.0.3-py3-none-any.whl (97 kB)
Collecting cffi>=1.4.1
Downloading cffi-1.15.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (444 kB)
Collecting six
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting yarl<2.0,>=1.0
Downloading yarl-1.7.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (304 kB)
Collecting attrs>=17.3.0
Downloading attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting chardet<5.0,>=2.0
Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting typing-extensions>=3.6.5
Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Collecting multidict<7.0,>=4.5
Downloading multidict-5.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (174 kB)
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Collecting idna>=2.0
Downloading idna-3.3-py3-none-any.whl (61 kB)
Installing collected packages: multidict, idna, yarl, typing-extensions, pycparser, MarkupSafe, chardet, attrs, async-timeout, Werkzeug, six, Jinja2, itsdangerous, click, cffi, aiohttp, PyNaCl, Flask, dnspython, discord.py
Successfully installed Flask-2.0.2 Jinja2-3.0.3 MarkupSafe-2.0.1 PyNaCl-1.3.0 Werkzeug-2.0.2 aiohttp-3.7.4.post0 async-timeout-3.0.1 attrs-21.4.0 cffi-1.15.0 chardet-4.0.0 click-8.0.3 discord.py-1.6.0 dnspython-1.16.0 idna-3.3 itsdangerous-2.0.1 multidict-5.2.0 pycparser-2.21 six-1.16.0 typing-extensions-4.0.1 yarl-1.7.2
-----> Discovering process types
Procfile declares types -> worker
-----> Compressing...
Done: 62M
-----> Launching...
Released v5
https://app.herokuapp.com/ deployed to Heroku
uj5u.com热心网友回复:
您的应用程序是一个作业程序 ( Procfile declares types -> worker
),因此它确实回应 HTTP 请求。
更改为web
并确保系结PORT
Heroku 提供的。
顺便说一句,如果 BOT 轮询服务器以获取讯息/更新,则它们可以作为作业程序运行(无需处理传入的请求)。这也是一个可行的选择(将其保留为 worker),但要确保 BOT 记录它在启动时所做的事情。
0 评论