python-3.x - 如何在正确的端口上链接到 Heroku 应用程序?
问题描述
我有一个 Oython 应用程序。这是一个带有aiohttp
. 我有一个requirements.txt
和Procfile
。我的部署阶段成功完成,但我不明白如何使用正确的端口打开应用程序。
我的应用程序监听 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
解决方案
Heroku 应用程序的
web
进程类型很特殊:它是唯一可以从 Heroku 路由器接收外部 HTTP 流量的进程类型。如果您的应用程序包含 Web 服务器,则应将其声明为应用程序的web
进程。
通过修改您的喜欢将您的主要流程类型从更改worker
为:web
Procfile
web: python index.py
推荐阅读
- c# - 报表定义可能是使用更高版本的 Reporting Services 创建的,或者包含格式不正确或无效的内容
- android - Android - 限制只有一位小数进入 TextView
- ruby-on-rails - 忽略重复记录的批量插入
- java - 如果 Java Annotation 上没有业务逻辑,那么 JavaEE 中的 @Entity 如何映射数据库中的类?
- mongodb - 如何使用 mongo 聚合对两个或多个字段进行分组以查找差异
- ionic4 - 设置离子选择文本
- sql - Big Query - 从临时表创建表/视图
- core-data - 重命名关系时的核心数据和 CloudKit 集成问题(代码 134110)
- python-3.x - 如何在下面的 HTML 代码中使用 xpath 识别具有相同文本的多个按钮元素?
- javascript - ExtJS 7.1 Tag 字段正在执行 XSS 标签