gunicorn

MaxMind GeoIP2 single instance in Django

我的梦境 提交于 2019-12-12 17:00:21
问题 I'm using python wrapper 'geoip2' for MaxMind's GeoIP database. It's said in the docs that you should create only single instance of the database reader, because opening the database is very expensive, and, of course, opening it for every request is a very bad idea. So, if I have Django (1.10) + Gunicorn on my server, how should I create the "singleton" of the database reader? That's generally not a question about geoip2 module, it's question about: How should I create a single object,

Streaming with gunicorn

送分小仙女□ 提交于 2019-12-12 12:27:52
问题 I'm trying to stream data from a flask/gunicorn server: while (True): result = json.dumps(tweetQueue.get()) yield result However, 30 seconds into the stream, gunicorn times out my connection and stops the stream. How can I make the timeout such that publishing new data to the stream from the server will restart the timeout so the stream will not be terminated? Thanks! 回答1: I am answering my own question after doing some more research. gunicorn server:app -k gevent This uses asynchronous

Django system-wide install to virtualenv

淺唱寂寞╮ 提交于 2019-12-12 10:24:10
问题 I've recently deployed an application online using DigitalOcean single-click droplet setup which setup Django on Ubuntu with nginx and gunicorn. It came with a default django project which I've managed to change to my own. However, the default project doesn't use a virtualenv, it uses a system-wide install. So, the app only works if all the dependencies are installed on the system. I know this because if I uninstall django, it gives me an internal server error. I would like to use the python

serving flask via nginx and gunicorn in docker

人盡茶涼 提交于 2019-12-12 10:01:31
问题 Playing around with flask I would like to get a real setup up and running in docker. This means flask should be served via nginx and gunicorn. I set up a sample code repository https://github.com/geoHeil/pythonServing but so far can't get nginx to work properly. Flask is served on application:5000 , docker should resolve application to its respective name. Nginx config is as follows: server { listen 8080; server_name application; charset utf-8; location / { proxy_pass http://application:5000;

What can go wrong if I use SimpleCache in my Flask app

匆匆过客 提交于 2019-12-12 08:53:01
问题 We are using the following setup: NGINX+Gunicorn+Flask. We need to add just a little bit of caching, no more than 5Mb per Flask worker. SimpleCache seems to be simplest possible solution - it uses memory locally, inside the Python process itself. Unfortunately, the documentation states the following: "Simple memory cache for single process environments. This class exists mainly for the development server and is not 100% thread safe." However, I fail to see where thread safety would matter at

Setup multiple django gunicorn instances with nginx

血红的双手。 提交于 2019-12-12 04:19:57
问题 Got one django site running with gunicorn & nginx need to setup another site also with the same. Nginx settings is straight forward, how to rework below to add another site /home/ubuntu/webapps/uganda_buzz/ relevant settings are /etc/init/gunicorn.conf description "Gunicorn application server handling all projects" start on runlevel [2345] stop on runlevel [!2345] respawn setuid user setgid www-data chdir /home/ubuntu/webapps/kenyabuzz exec /home/ubuntu/webapps/djangoenv/bin/gunicorn -

Bad Gateway 502 Error with Django, Gunicorn and Nginx

走远了吗. 提交于 2019-12-12 04:07:21
问题 I am trying to run project on Django with Gunicorn and Nginx. On DigitalOcean OneClick install image my project works fine with no virtualenv and with global Django installation. But when I created virtual environment for different Django version I couldn't get it to work. So kindly someone please provide me some help with the multi site hosting on Ubuntu using virtual environment. Follwing is my Gunicorn settings for virtual environment: description "Gunicorn daemon for Django project" start

Why is Cassandra hanging when I connect to it via Gunicorn and Flask?

左心房为你撑大大i 提交于 2019-12-12 03:27:49
问题 I have a Flask app that connects to Cassandra. When I run this app under Gunicorn and invoke Gunicorn as a flask-script command python manage.py gunicorn , it hangs. But when I run this same app on the command line as gunicorn manage:app , it succeeds. Why? 回答1: Explanation Gunicorn forks off workers to handle incoming requests. If the Cassandra session (connection pool) is created before the worker fork (e.g., during app creation using an application factory pattern), the workers will have

http request inside gunicorn causes gunicorn response to fail?

旧时模样 提交于 2019-12-12 02:46:31
问题 I'm running the below code slightly modfied from gunicorn's website (http://gunicorn.org/run.html) import urllib2 def app(environ, start_response): print "in app" # response=urllib2.urlopen('http://www.google.com') data = 'Hello, World!\n' response_headers = [ ('Content-type','text/plain'), ('Content-Length', str(len(data))) ] start_response('200 OK', response_headers) print " starting response" return iter([data]) It runs completely as expected except when I uncomment the urrllib2.urlopen

Restart Gunicorn_django via Fabric

你。 提交于 2019-12-11 20:33:31
问题 I'm building a Django application and I decided to investigate Fabric for automating deployment. I've got it mostly working, but it fails at the last step, and I can't seem to puzzle out why. I'm using Nginx and Gunicorn to serve the application, and I want to kill and restart Gunicorn after the changes have been pulled in and the database updated. Unfortunately it always seems to fail at the last hurdle. The final command doesn't respond with any kind of error, but the application isn't