问题描述
我在 aiohttp 上构建了一个简单的 Web 服务器并尝试将它部署在 heroku 上,但在部署后我收到一条错误消息:
I have built a simple web server on aiohttp and try to deploy it on heroku, but after deployment I get an error message:
at=error code=H14 desc="No web processes running" dyno= connect= service= status=503 bytes= protocol=https
项目结构:
├── application.py
├── Procfile
├── requirements.txt
├── routes.py
└── views
├── bot_team_oranizer.py
├── index.py
└── __init__.py
application.py
from aiohttp import web
from routes import setup_routes
app = web.Application()
setup_routes(app)
web.run_app(app)
Procfile:
web: gunicorn application:app
为什么网络服务器没有在 heroku 上启动?
Why is the web server not starting on heroku?
推荐答案
可能 aiohttp 没有监听正确的端口.你需要像 web.run_app(app, port=os.getenv('PORT'))
之类的东西.
Probably aiohttp isn't listening on the right port. You need something like web.run_app(app, port=os.getenv('PORT'))
.
更新: 等等,您正在尝试同时使用 gunicorn 和 web.run_app
来提供它,这是错误的,您需要使用类似web: python application.py
或删除web.run_app(app)
.
Update: wait, you're trying to serve it both with gunicorn and with web.run_app
which is wrong, you'll need to either just have something like web: python application.py
or remove the web.run_app(app)
.
这篇关于在heroku上部署aiohttp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!