我使用flask和python(2.7)。我构建了一个在localhost上运行没有问题的应用程序,但现在它不会在heroku上运行。
运行heroku log时我得到的错误--tail是: 运行heroku重启:
Summary
我已经尝试了我能找到的大部分内容,我甚至将app.run()更改为空而不是 17-05-25T17:22:27.879428+00:00 heroku[web.1]: Starting process with command `python project.py`
2017-05-25T17:22:32.083014+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-05-25T17:22:32.086435+00:00 app[web.1]: * Restarting with stat
2017-05-25T17:22:32.410829+00:00 app[web.1]: * Debugger is active!
2017-05-25T17:22:32.425538+00:00 app[web.1]: * Debugger PIN: 308-659-015
2017-05-25T17:23:23.016962+00:00 heroku[web.1]: Restarting
2017-05-25T17:23:23.879234+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-05-25T17:23:24.135864+00:00 heroku[web.1]: Process exited with status 0
2017-05-25T17:23:26.983758+00:00 heroku[web.1]: Starting process with command `python project.py`
2017-05-25T17:23:31.588440+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-05-25T17:23:31.591852+00:00 app[web.1]: * Restarting with stat
2017-05-25T17:23:32.223153+00:00 app[web.1]: * Debugger is active!
2017-05-25T17:23:32.247252+00:00 app[web.1]: * Debugger PIN: 211-683-280
2017-05-25T17:23:57.249472+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=park-picker.herokuapp.com request_id=061f52b3-38e4-4126-b6e3-90129eff15a8 fwd="73.240.112.202" dyno= connect= service= status=503 bytes= protocol=https
2017-05-25T17:22:27.879428+00:00 heroku[web.1]: Starting process with command `python project.py`
2017-05-25T17:22:32.083014+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-05-25T17:22:32.086435+00:00 app[web.1]: * Restarting with stat
2017-05-25T17:22:32.410829+00:00 app[web.1]: * Debugger is active!
2017-05-25T17:22:32.425538+00:00 app[web.1]: * Debugger PIN: 308-659-015
2017-05-25T17:23:23.016962+00:00 heroku[web.1]: Restarting
2017-05-25T17:23:23.879234+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-05-25T17:23:24.135864+00:00 heroku[web.1]: Process exited with status 0
2017-05-25T17:23:26.983758+00:00 heroku[web.1]: Starting process with command `python project.py`
2017-05-25T17:23:31.588440+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-05-25T17:23:31.591852+00:00 app[web.1]: * Restarting with stat
2017-05-25T17:23:32.223153+00:00 app[web.1]: * Debugger is active!
2017-05-25T17:23:32.247252+00:00 app[web.1]: * Debugger PIN: 211-683-280
2017-05-25T17:23:57.249472+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=park-picker.herokuapp.com request_id=061f52b3-38e4-4126-b6e3-90129eff15a8 fwd="73.240.112.202" dyno= connect= service= status=503 bytes= protocol=https
2017-05-25T17:24:27.034926+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-05-25T17:24:27.034926+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-05-25T17:24:27.206980+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-25T17:24:27.186502+00:00 heroku[web.1]: Process exited with status 137
2017-05-25T17:24:28.221792+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=park-picker.herokuapp.com request_id=cac9dc85-6e54-4bbe-b0a1-91f0a4fd5531 fwd="73.240.112.202" dyno= connect= service= status=503 bytes= protocol=https
2017-05-25T17:24:29.063671+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=park-picker.herokuapp.com request_id=04215139-8e22-4d61-9e28-8fddab312da4 fwd="73.240.112.202" dyno= connect= service= status=503 bytes= protocol=https
2017-05-25T17:24:29.750162+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=park-picker.herokuapp.com request_id=6db46984-3a90-4dc8-af96-b0bbf97e1f4c fwd="73.240.112.202" dyno= connect= service= status=503 bytes= protocol=https
以试图允许heroku定义它自己(我相信它会导致H20错误,这已被改回)。
我的proc文件是:
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 33507)))
和我的requirements.txt是由。生成的
web: python project.py
该项目最初是使用VM构建的,所以我甚至尝试删除Vagrant文件,但没效果。
非常感谢任何帮助,我感到茫然,谢谢!
答案 0 :(得分:1)
在project.py
我错过了import os
声明
问题已解决。