我正在部署一个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

推荐答案

在proc文件中将"web"替换为"worker".

Python-3.x相关问答推荐

如何在输入正确的用户名和密码时添加按钮?

如何从包含SPAN文本的标记中获取链接

我没有';无法理解此TemplateDoesNotExist错误

如何使用 Selenium Python 连续单击一个按钮直到另一个元素出现?

基于其他列的条件向Panda数据框中添加值到新列

从 LeetCode 的 Python 解决方案类中理解关键字 self

Jupyter Notebook 拒绝打印一些字符串

协议不支持地址系列在将 Scapy L3socket 与 WSL 一起使用时

通过最接近的匹配合并两个不同长度的列上的两个数据框

Python BeautifulSoup:在 Select 语句中排除其他标签

如何准确测定cv2的结果.在BW/黑白图像中查找对象?

TimescaleDB:是否可以从 Python 调用create_hypertable?

在python中基于列表理解的条件下跳过元素

smtplib 在 Python 3.1 中发送带有 unicode 字符的邮件的问题

如何模拟 Django 模型对象(及其方法)?

Python 错误:IndexError:字符串索引超出范围

如何在不使用 @hydra.main() 的情况下获取 Hydra 配置

如何使用 d.items() 更改 for 循环中的所有字典键?

如何在 jupyter notebook 5 中逐行分析 python 3.5 代码

将列表列表转换为Python中的字典字典