社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  tornado

Heroku上的Tornado服务器。错误R10(启动超时)

OntologicalSin • 6 年前 • 2446 次点击  

我正在尝试部署一个使用Tornado服务器用Python编写的Web应用程序。

在我的 app.py 我有

if __name__ == '__main__':
    server = tornado.httpserver.HTTPServer(Application())
    server.listen(4200, address='0.0.0.0')
    tornado.ioloop.IOLoop.instance().start()

然后我有一个程序文件 web: python app.py

当我检查日志时,我看到了错误

2018-08-08T02:20:54.117821+00:00 heroku[web.1]: Starting process with command `python app.py`
2018-08-08T02:20:57.000000+00:00 app[api]: Build succeeded
2018-08-08T02:21:54.891301+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-08-08T02:21:54.891301+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-08-08T02:21:55.027586+00:00 heroku[web.1]: Process exited with status 137
2018-08-08T02:21:55.049407+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-08T02:21:55.051776+00:00 heroku[web.1]: State changed from crashed to starting
2018-08-08T02:21:59.562357+00:00 heroku[web.1]: Starting process with command `python app.py`

我不太清楚自己在做什么,尤其是 Procfile 所以我猜问题就在那里。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/33255
 
2446 次点击  
文章 [ 1 ]  |  最新文章 6 年前
Chris
Reply   •   1 楼
Chris    6 年前

赫鲁库 tells you which port you should bind to via the PORT environment variable . 您应该使用它而不是对端口进行硬编码,例如

import os

port = int(os.getenv('PORT', 4200))
server.listen(port, address='0.0.0.0')

这将使用 端口 如果存在环境变量(如Heroku上),则返回到4200(如开发机器上)。