我正在尝试通过Heroku部署一个简单的Flask应用程序,但是却收到H10错误。我正在Heroku网站上与Github一起手动部署。
我已经尝试过使用命令'heroku restart',heroku ps:scale web = 1,pip Frozen> requirements.txt和dynos并将我的Procfile更改为包括-b:$ PORT,在我的flask python中更改PORT文件更改为app.run(debug = True,port = 33507,port = int(os.environ.get('PORT',5000))和app.run(host ='0.0.0.0',port = port)我的仓库要匹配https://github.com/zachwill/flask_heroku,然后将gunicorn和gevent添加到requirements.txt。
应用
port = int(os.environ.get('PORT', 5000))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=port)
Procfile
web: gunicorn -b :$PORT flaskapp:app
requirements.txt
gunicorn
gevent
错误
2019-07-08T19:29:05.872509+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-08T19:29:05.497279+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-07-08T19:29:05.498369+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Listening at: http://0.0.0.0:39703 (4)
2019-07-08T19:29:05.498552+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Using worker: sync
2019-07-08T19:29:05.505408+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [INFO] Booting worker with pid: 10
2019-07-08T19:29:05.539492+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [ERROR] Exception in worker process
2019-07-08T19:29:05.539497+00:00 app[web.1]: Traceback (most recent call last):
2019-07-08T19:29:05.539499+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-08T19:29:05.539501+00:00 app[web.1]: worker.init_process()
2019-07-08T19:29:05.539503+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-08T19:29:05.539507+00:00 app[web.1]: self.load_wsgi()
2019-07-08T19:29:05.539510+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-08T19:29:05.539512+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-08T19:29:05.539514+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-08T19:29:05.539516+00:00 app[web.1]: self.callable = self.load()
2019-07-08T19:29:05.539518+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-08T19:29:05.539520+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-08T19:29:05.539522+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-08T19:29:05.539524+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-08T19:29:05.539526+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-08T19:29:05.539528+00:00 app[web.1]: __import__(module)
2019-07-08T19:29:05.539530+00:00 app[web.1]: File "/app/flaskapp.py", line 4, in <module>
2019-07-08T19:29:05.539532+00:00 app[web.1]: from pml import app
2019-07-08T19:29:05.539577+00:00 app[web.1]: ModuleNotFoundError: No module named 'pml'
2019-07-08T19:29:05.539825+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-07-08T19:29:05.555645+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [INFO] Booting worker with pid: 11
2019-07-08T19:29:05.574207+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [ERROR] Exception in worker process
2019-07-08T19:29:05.574212+00:00 app[web.1]: Traceback (most recent call last):
2019-07-08T19:29:05.574214+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-08T19:29:05.574216+00:00 app[web.1]: worker.init_process()
2019-07-08T19:29:05.574218+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-08T19:29:05.574220+00:00 app[web.1]: self.load_wsgi()
2019-07-08T19:29:05.574222+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-08T19:29:05.574224+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-08T19:29:05.574226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-08T19:29:05.574228+00:00 app[web.1]: self.callable = self.load()
2019-07-08T19:29:05.574230+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-08T19:29:05.574232+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-08T19:29:05.574234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-08T19:29:05.574236+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-08T19:29:05.574238+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-08T19:29:05.574240+00:00 app[web.1]: __import__(module)
2019-07-08T19:29:05.574242+00:00 app[web.1]: File "/app/flaskapp.py", line 4, in <module>
2019-07-08T19:29:05.574244+00:00 app[web.1]: from pml import app
2019-07-08T19:29:05.574246+00:00 app[web.1]: ModuleNotFoundError: No module named 'pml'
2019-07-08T19:29:05.574494+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-07-08T19:29:05.682720+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Shutting down: Master
2019-07-08T19:29:05.682883+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-07-08T19:29:05.849393+00:00 heroku[web.1]: Process exited with status 3
2019-07-08T19:35:15.978510+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=randommovieroulette.herokuapp.com request_id=4e2ad446-cd8a-4136-9875-f94381259b5e fwd="173.71.157.150" dyno= connect= service= status=503 bytes= protocol=https
2019-07-08T19:35:18.311763+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=randommovieroulette.herokuapp.com request_id=154f2f1f-afeb-4765-8e05-1f908fe2d0f4 fwd="173.71.157.150" dyno= connect= service= status=503 bytes= protocol=https
应用正在“部署”,但是服务器端出了点问题。使用我当前的python版本制作runtime.txt会阻止应用程序部署。那我应该把它改成其他版本吗?我是新手,所以如果我犯了一个简单的错误,我深表歉意。
答案 0 :(得分:0)
Requirements.txt不包含flask_wtf,bs4,请求或应用程序,所有这些均导入了我的flaskapp.py文件中。该文件以前仅包含gunicorn和gevent。