Been playing with Python Flask writing some backend REST API for our game backend.
Trying to work on deploying the API using Gunicorn using gevent
sudo apt-get install libevent-1.4-2 sudo apt-get install libevent-dev easy_install greenlet easy_install gevent
My Gunicorn config file:
$ cat gunicorn.py import os def numCPUs(): if not hasattr(os, "sysconf"): raise RuntimeError("No sysconf detected.") return os.sysconf("SC_NPROCESSORS_ONLN") bind = "0.0.0.0:8000" workers = numCPUs() * 2 + 1 backlog = 2048 #worker_class ="sync" worker_class = "gevent" debug = True daemon = True pidfile ="/tmp/gunicorn.pid" logfile ="/tmp/gunicorn.log"
Running the Flask Application:
$ gunicorn -c gunicorn.py mp:app
$ tail /tmp/gunicorn.log 2011-04-19 10:33:40 [1594] [INFO] Starting gunicorn 0.12.1 2011-04-19 10:33:40 [1594] [INFO] Listening at: http://0.0.0.0:8000 (1594) 2011-04-19 10:33:40 [1594] [INFO] Using worker: gevent 2011-04-19 10:33:40 [1595] [INFO] Booting worker with pid: 1595 2011-04-19 10:33:40 [1596] [INFO] Booting worker with pid: 1596 2011-04-19 10:33:40 [1597] [INFO] Booting worker with pid: 1597
Woops.. seems working.
Time to run load testing with ab and siege.
Have you tried your Flask + gunicorn set up via supervisord? Im having some issues and wondering if you ran into any weirdness.
Hi Angel,
I’m sure you have check the logs for any possible errors. I haven’t used supervisord for Flask+gunicorn yet.