我最近成功部署了一個 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并確保系結PORTHeroku 提供的。
順便說一句,如果 BOT 輪詢服務器以獲取訊息/更新,則它們可以作為作業程式運行(無需處理傳入的請求)。這也是一個可行的選擇(將其保留為 worker),但要確保 BOT 記錄它在啟動時所做的事情。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/404426.html
標籤:
