【问题标题】:python - Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launchpython - 错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT
【发布时间】:2016-11-01 08:06:43
【问题描述】:

我正在heroku 部署一个python 脚本,它会在每个3 minutes 之后向另一台服务器发出请求。

部署进展顺利,但当我看到logs 时,我得到了这些errors。

2016-11-01T07:42:12.919755+00:00 heroku[web.1]: Starting process with command `python script.py --log-file -`
2016-11-01T07:43:13.097413+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-11-01T07:43:13.097556+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-11-01T07:43:13.196156+00:00 heroku[web.1]: Process exited with status 137
2016-11-01T07:43:13.212942+00:00 heroku[web.1]: State changed from starting to crashed
2016-11-01T07:43:13.213858+00:00 heroku[web.1]: State changed from crashed to starting
2016-11-01T07:43:16.719828+00:00 heroku[web.1]: Starting process with command `python script.py --log-file -`
2016-11-01T07:44:17.215381+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-11-01T07:44:17.215381+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-11-01T07:44:17.364708+00:00 heroku[web.1]: Process exited with status 137
2016-11-01T07:44:17.367610+00:00 heroku[web.1]: State changed from starting to crashed 

Procfile

web: python script.py --log-file -

script.py

import sys
import requests
from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()

@sched.scheduled_job('interval', minutes=3)
def timed_job():
    try:
        request = requests.get(url='https://royal-tag-services.herokuapp.com/api/sms-service/scheduler/')
    except Exception as e:
        print >>sys.stderr, 'scheduler request failed'

sched.start()

Result of 'tree -L 1' command

├── Procfile
├── requirements.txt
├── script.py
└── supporterenv

【问题讨论】:

    标签: python python-2.7 python-3.x heroku


    【解决方案1】:

    在您的 Procfile 中将“web”替换为“worker”。

    【讨论】:

    • 我认为它正在工作。但这就是我看到错误时得到的。 2016-11-01T08:22:20.356683+00:00 heroku[api]:通过 adil.azeem@mezino.com 部署 96b1efe 2016-11-01T08:22:20.356782+00:00 heroku[api]:发布 v10 创建者adil.azeem@mezino.com 2016-11-01T08:22:20.422315+00:00 heroku[web.1]:状态从崩溃变为关闭 2016-11-01T08:22:20.572330+00:00 heroku[slug- compiler]: Slug 编译开始 2016-11-01T08:22:20.572340+00:00 heroku[slug-compiler]: Slug 编译完成
    • 如果您的 Procfile 中有“web”进程类型,运行该进程的 dyno 必须在 60 秒内(默认情况下)绑定到其分配的 $PORT,以便能够响应传入的通过 http/s 的网络请求。如果没有,Heroku 会按照devcenter.heroku.com/articles/error-codes#r10-boot-timeout 中的说明删除测功机。由于您的 python 脚本不是 web 服务器,因此 Procfile 中的条目不应定义为“web”进程类型。
    • 在我的情况下,虽然它在将“web”替换为“worker”后工作,但它提出了另一个问题“at=error code=H14 desc="No web processes running"”,有没有办法避免这两种情况?
    • @MemphisMeng "at=error code=H14 desc="No web processes running" 这意味着你没有任何正在运行的 web dynos 首先运行 heroku ps:scale web=1 然后打开你的应用程序
    • 注意:你需要运行heroku ps:scale worker=1,因为worker不会自动扩展(你应该运行heroku ps:scale web=0来移除web cpu)
    猜你喜欢
    • 2021-04-05
    • 2021-08-19
    • 2019-04-20
    • 2021-01-14
    • 2019-07-04
    • 2019-02-15
    • 1970-01-01
    • 2018-10-16
    • 1970-01-01
    相关资源
    最近更新 更多