Gunicorn keeps restarting / crashing in flash app

I have a flack app. I am trying to move to launch through cannons. I have a lot of problems with that. Here's the startup code for my application:

app.run(host=HOST, port=PORT, debug=DEBUG_FLAG)

      

First, if DEBUG_FLAG == true, the application will never start, but will simply restart and local push will not work. He just does it over and over:

gunicorn analytics_service:app                                                                                                                         
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader

      

If I start it with DEBUG_FLAG == False, it actually starts up and serves some requests, but it still interrupts and restarts for unknown reasons:

gunicorn analytics_service:app                                                                                                                         (env: BigQueryTest)
 * Running on http://127.0.0.1:5000/
127.0.0.1 - - [28/Aug/2014 08:59:05] "GET /metrics/ctr?location=blah&start_date=2014-05-21&end_date=2014-06-01 HTTP/1.1" 200 -
127.0.0.1 - - [28/Aug/2014 08:59:15] "GET /metrics/ctr?location=blah&start_date=2014-05-21&end_date=2014-06-05 HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 64693)
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/Users/Eli/.virtualenvs/BigQueryTest/lib/python2.7/site-packages/werkzeug/serving.py", line 200, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/Users/Eli/.virtualenvs/BigQueryTest/lib/python2.7/site-packages/werkzeug/serving.py", line 231, in handle_one_request
    self.raw_requestline = self.rfile.readline()
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
  File "/Users/Eli/.virtualenvs/BigQueryTest/lib/python2.7/site-packages/gunicorn/workers/base.py", line 154, in handle_abort
    sys.exit(1)
SystemExit: 1
----------------------------------------
 * Running on http://127.0.0.1:5000/
 * Running on http://127.0.0.1:5000/
 * Running on http://127.0.0.1:5000/
 * Running on http://127.0.0.1:5000/
 * Running on http://127.0.0.1:5000/

      

As mentioned, everything works fine if I run my own Flask server. Problems only arise with the cannon. Help?

+3


source to share


1 answer


I suspect your problem is what you are calling app.run()

.

The function app.run()

starts the development flags web server. When you are using a webserver other than Flask, you don't need to call this function, your webserver (in this case the gunner) will have its own way to start.



Usually the string app.run()

is inside a condition if __name__ == '__main__':

(see the official Flask documentation for an example), so it only runs when the script is executed directly, as in python run.py

. I recommend you add this to your run.py script and check again. If there are any problems, please describe.

+4


source







All Articles