简体   繁体   中英

Gunicorn and Gevent crashing Flask app on Heroku

I upgraded my app on Heroku to use Flask 0.9 and the new Gevent and since then have been unable to get the app to work on Heroku. It runs just fine using python web_app.py in the Procfile but using:

web: gunicorn web_app:app -w 3 -b 0.0.0.0:$PORT -k gevent --max-requests 250

where the entry point of a application is a file aptly named web_app.py.

I reduced it to a basic "hello world" and still, a crash. I also tried without Gunicorn, running it with just a Gevent server as described in the other servers section of the Flask documentation but again, instant crash. I'm thinking either I've messed up my environment some how or my requirements.txt is screwy.

Here's my requirements.txt file:

jinja2
werkzeug
flask
wtforms
gevent
gunicorn
psycopg2
sqlalchemy
itsdangerous
flask-seasurf
flask-login
flask-debugtoolbar
flask-sqlalchemy
flask-script
flask-uploads
flask-failsafe
requests
alembic
braintree
cloudinary

Any help would be appreciated as it can not handle any meaningful traffic using the default server in Flask. Is there more information I need to provide?

EDIT:

Here's the error

app/web.1:  2012-12-08 21:18:22 [7] [INFO] Booting worker with pid: 7
app/web.1:  2012-12-08 21:18:22 [7] [INFO] Worker exiting (pid: 7)
app/web.1:  2012-12-08 21:18:22 [6] [INFO] Worker exiting (pid: 6)
app/web.1:  2012-12-08 21:18:22 [5] [INFO] Worker exiting (pid: 5)
app/web.1:  Traceback (most recent call last):
app/web.1:  File "/app/.heroku/venv/bin/gunicorn", line 12, in <module>
app/web.1:  load_entry_point('gunicorn==0.14.6', 'console_scripts', 'gunicorn')()
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 32, in run
app/web.1:  WSGIApplication("%prog [OPTIONS] APP_MODULE").run()
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/app/base.py", line 124, in run
app/web.1:  Arbiter(self).run()
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 185, in run
app/web.1:  self.halt(reason=inst.reason, exit_status=inst.exit_status)
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 280, in halt
app/web.1:  self.stop()
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 328, in stop
app/web.1:  self.reap_workers()
app/web.1:  File "/app/.heroku/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 419, in reap_workers
app/web.1:  raise HaltServer(reason, self.WORKER_BOOT_ERROR)
app/web.1:  gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

Due note, I have taken out all print statements that I erroneously left in and this has not helped at all.

I just used the solution to Heroku-fails-to-start-my-app-but-foreman-start-works question. In case people are wondering, I've enclosed by app create in this method call:

@failsafe
def create_app():
  from routes import app
  return app

and have structured my Profile as instructed in that answer:

web: gunicorn legalkin_app:create_app\(\) -w 3 -b 0.0.0.0:$PORT -k gevent --max-requests 250

Side note, I have done something dumb to have to do this but I have no idea what it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM