我有一个使用flask flask.io的flask应用程序,它在本地运行良好,但是最初当我部署到heroku时,Procfile就是这个
web: gunicorn script:app
然后,即使页面已加载,socket.io也不工作,没有任何返回。然后我在网上查看,发现procfile应该像
web: gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 script:app --timeout 90
我对此进行了更新,并推送到heroku,现在它只是说我的应用存在错误,日志跟踪如下。
Release v18 created by user my_user_name
2019-06-23T20:03:46.775654+00:00 app[api]: Deploy 45f12d9d by user my_user_name
2019-06-23T20:04:03.388864+00:00 heroku[web.1]: Starting process with command `gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 script:app --timeout 90`
2019-06-23T20:04:07.184235+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/ggevent.py:70: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016
2019-06-23T20:04:07.184261+00:00 app[web.1]: monkey.patch_all()
2019-06-23T20:04:07.184616+00:00 app[web.1]: 2019-06-23 20:04:07 [4] [INFO] Starting gunicorn 18.0
2019-06-23T20:04:07.185506+00:00 app[web.1]: 2019-06-23 20:04:07 [4] [INFO] Listening at: http://0.0.0.0:5977 (4)
2019-06-23T20:04:07.185656+00:00 app[web.1]: 2019-06-23 20:04:07 [4] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
2019-06-23T20:04:07.191560+00:00 app[web.1]: 2019-06-23 20:04:07 [10] [INFO] Booting worker with pid: 10
2019-06-23T20:04:07.982269+00:00 heroku[web.1]: State changed from starting to up
2019-06-23T20:04:08.128858+00:00 app[web.1]: Using TensorFlow backend.
2019-06-23T20:04:18.035292+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=Mk5y1QQ" host=tweet-generation.herokuapp.com request_id=c42fd774-5e7b-4096-9a29-268ff178e6ce fwd="129.97.124.57" dyno=web.1 connect=1ms service=9310ms status=200 bytes=357 protocol=https
2019-06-23T20:04:18.495198+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=Mk5y7kJ" host=tweet-generation.herokuapp.com request_id=5ad22a7e-1a12-4d4c-b933-f7f46ce03ed6 fwd="129.97.124.57" dyno=web.1 connect=1ms service=2ms status=200 bytes=357 protocol=https
2019-06-23T20:04:30.000000+00:00 app[api]: Build succeeded
2019-06-23T20:04:48.537239+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/socket.io/?EIO=3&transport=polling&t=Mk5y7l1&sid=633f2f874ba64f798bb6ed459a3c7ce3" host=tweet-generation.herokuapp.com request_id=cd025ff3-3033-4c73-8c36-9909e8cb0c65 fwd="129.97.124.57" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2019-06-23T20:04:48.598648+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/socket.io/?EIO=3&transport=websocket&sid=633f2f874ba64f798bb6ed459a3c7ce3" host=tweet-generation.herokuapp.com request_id=31b69870-2f53-4ec6-a0d2-edbe39919913 fwd="129.97.124.57" dyno=web.1 connect=0ms service=30004ms status=503 bytes=0 protocol=https