我正在尝试托管一个使用tensorflow到heroku的瓶子应用程序,应用程序启动,我也得到了'服务器在端口上运行'。但应用程序没有打开,大约一分钟后,它显示下面的跟踪
打开跟踪说服务器运行成功,
2018-08-25T19:46:55.651043+00:00 heroku[web.1]: Starting process with command `python ./api.py -p 37040`
2018-08-25T19:47:01.379243+00:00 app[web.1]: Bottle v0.12.13 server starting up (using WSGIRefServer())...
2018-08-25T19:47:01.379274+00:00 app[web.1]: Listening on http://127.0.0.1:8080/
2018-08-25T19:47:01.379309+00:00 app[web.1]: Hit Ctrl-C to quit.
2018-08-25T19:47:01.379318+00:00 app[web.1]:undefined
几分钟后。错误跟踪。
2018-08-25T19:47:56.239318+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-08-25T19:47:56.239392+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-08-25T19:47:56.330436+00:00 heroku[web.1]: Process exited with status 137
2018-08-25T19:47:56.353021+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-25T19:47:59.452460+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-forest-70642.herokuapp.com request_id=8b62b91c-8f22-4c37-b3c5-cbc7e8415e3d fwd="123.231.104.11" dyno= connect= service= status=503 bytes= protocol=https
2018-08-25T19:47:59.500660+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=boiling-forest-70642.herokuapp.com request_id=e8860f29-40fd-46b1-b9f2-96683f53d524 fwd="123.231.104.11" dyno= connect= service= status=503 bytes= protocol=https
2018-08-25T19:48:02.118233+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-forest-70642.herokuapp.com request_id=1f9aafbe-f410-46ab-84ed-41bbc90857e6 fwd="123.231.104.11" dyno= connect= service= status=503 bytes= protocol=https
我不知道我做错了什么,因为我是heroku或者瓶子的新手。
procfile:
web: python ./api.py -p $PORT
api.py文件
@get('/')
def get_top_predictions():
#lable_index, labels_list, results_list = li.get_lables("bottle.jpg")
#selected_list = [{"class": labels_list[i], "probability": float(results_list[i]) } for i in lable_index]
#return {"predictions": selected_list}
return {"predictions": "Hello Man"}
run()
我也试过像设置run(host='0.0.0.0')
一样的选项。仍然没有工作,并给出相同的错误信息。
有人能告诉我这有什么问题吗?
您的应用需要绑定到外部可见地址上的Heroku提供的端口。你有两种成分,只是没有正确混合在一起。您尝试了run(host='0.0.0.0')
并在Procfile中包含-p $PORT
,但是没有显示指示如何使用它的代码。
试试这个:
run(host='0.0.0.0', port=os.environ.get('PORT', '5000'))