首页 > 解决方案 > 如何在正确的端口上链接到 Heroku 应用程序?

问题描述

我有一个 Oython 应用程序。这是一个带有aiohttp. 我有一个requirements.txtProcfile。我的部署阶段成功完成,但我不明白如何使用正确的端口打开应用程序。

我的应用程序监听 HerokuPORT环境。

Heroku 日志返回:

2019-04-19T13:34:44.150477+00:00 app[api]: Release v7 created by user 
doubledare704@gmail.com
2019-04-19T13:34:44.150477+00:00 app[api]: Deploy 1b35a335 by user 
doubledare704@gmail.com
2019-04-19T13:34:45.357983+00:00 heroku[worker.1]: State changed from 
crashed to starting
2019-04-19T13:34:48.854124+00:00 heroku[worker.1]: Starting process with 
command `python index.py`
2019-04-19T13:34:49.473879+00:00 heroku[worker.1]: State changed from 
starting to up
2019-04-19T13:34:51.167617+00:00 app[worker.1]: ======== Running on 
http://0.0.0.0:10303 ========
2019-04-19T13:34:51.167652+00:00 app[worker.1]: (Press CTRL+C to quit)
2019-04-19T13:34:54.000000+00:00 app[api]: Build succeeded
2019-04-19T13:35:05.578025+00:00 heroku[router]: at=error code=H14 desc="No 
web processes running" method=GET path="/" host=google-adschecker- 
704.herokuapp.com request_id=8a85c812-a4b9-4d8f-98f6-91a8ff557594 
fwd="93.170.115.160" dyno= connect= service= status=503 bytes= protocol=https
2019-04-19T13:35:05.888452+00:00 heroku[router]: at=error code=H14 desc="No 
web processes running" method=GET path="/favicon.ico" host=google- 
adschecker-704.herokuapp.com request_id=a7be2157-523c-4d00-9a26-a68e7d40e1fd 
fwd="93.170.115.160" dyno= connect= service= status=503 bytes= protocol=https

H14 错误说关于测功机,但我打开了 1 个测功机。如何将所有 HTTP 请求切换到该端口?或者如何管理 Heroku 上的设置?

这是我的Procfile

worker: python index.py

标签: python-3.xherokuportadmin

解决方案


工作人员无法接收来自互联网的网络请求

Heroku 应用程序的web进程类型很特殊:它是唯一可以从 Heroku 路由器接收外部 HTTP 流量的进程类型。如果您的应用程序包含 Web 服务器,则应将其声明为应用程序的web进程。

通过修改您的喜欢将您的主要流程类型从更改worker为:webProcfile

web: python index.py

推荐阅读