gunicorn

Can one small portion of an app use gevent, or does the whole app have to switch over?

被刻印的时光 ゝ 提交于 2019-12-06 11:47:10
I have an already written large app using standard python threading constructs such as threads, queues, normal sockets, and multiprocessing. It has a web frontend implemented using Flask. I want to expose a certain part of the apps state in real time using websockets. I looked into Flask-Sockets which uses gevent and gunicorn. Does my whole app have to use the event-driven model, or can I leave the rest of the blocking code the way it is? (Basic tests seem to having both blocking and evented code, but are there any caveats and will I have to rewrite a large portion of the code?) I haven't

Gunicorn graceful stopping with docker-compose

拈花ヽ惹草 提交于 2019-12-06 10:06:28
问题 I find that when I use docker-compose to shut down my gunicorn (19.7.1) python application, it always takes 10s to shut down. This is the default maximum time docker-compose waits before forcefully killing the process (adjusted with the -t / --timeout parameter). I assume this means that gunicorn isn't being gracefully shut down. I can reproduce this with: docker-compose.yml: version: "3" services: test: build: ./ ports: - 8000:8000 Dockerfile: FROM python RUN pip install gunicorn COPY test

Gunicorn + Gevent : Debugging workers stuck state/ WORKER TIMEOUT cause

牧云@^-^@ 提交于 2019-12-06 08:22:17
问题 I'm running a very simple web server using Django on Gunicorn with Gevent workers which communicate with MySQL for simple crud type operations. All of this is behind nginx and hosted on AWS. I'm running my app server using the following config: gunicorn --logger-class=simple --timeout 30 -b :3000 -w 5 -k gevent my_app.wsgi:application However, sometimes, the workers just get stuck (sometimes when # of requests increase. Sometimes even without it)and the TPS drops with nginx returning 499 HTTP

Gunicorn exits because https request from Django fails in OpenSSL

五迷三道 提交于 2019-12-06 07:31:59
问题 Here's the scenario. I have a Django app being served by Gunicorn on Linux. On certain requests it makes an https call to an external API via httplib2.request() . Sometimes that call fails in such a way that hoses OpenSSL (not sure how, but it's not my fault and doesn't really matter). OpenSSL sends a SIGABRT signal to gunicorn in this case. Gunicorn handles the SIGABRT and promptly system exits (as it should). The root issue as I see it is that OpenSSL asynchronously signals the parent

Nginx: Permission denied to Gunicorn socket on CentOS 7

≯℡__Kan透↙ 提交于 2019-12-06 07:28:26
问题 I'm working in a Django project deployment. I'm working in a CentOS 7 server provided ma EC2 (AWS). I have tried to fix this bug by many ways but I cant understand what am I missing. I'm using ningx and gunicorn to deploy my project. I have created my /etc/systemd/system/myproject.service file with the following content: [Unit] Description=gunicorn daemon After=network.target [Service] User=centos Group=nginx WorkingDirectory=/home/centos/myproject_app ExecStart=/home/centos/myproject_app

Can't reach Django default app via Gunicorn on AWS EC2 instance

纵然是瞬间 提交于 2019-12-06 02:55:01
I've been struggling with this problem for two days without success. I've created an instance of the default Django (1.6.1) app called "testdj", installed it on an Amazon AWS EC2 t1.micro instance running Ubuntu Server 13.10, and I'm trying to reach the default Django "It worked!" page via Gunicorn (v. 18). When I start gunicorn from the command line: gunicorn testdj.wsgi:application --bind [ec2-public-dns]:8001 I can see the page when I enter this URL: http://[ec2-public-dns]:8001 However, if I use a "start-gunicorn" bash script I created after reading Karzynski's blogpost "Setting Up Django

How is Python scaling with Gunicorn and Kubernetes?

∥☆過路亽.° 提交于 2019-12-06 02:15:11
I am going to deploy a Python Flask Server with Docker on Kubernetes using Gunicorn and Gevent/Eventlet as asynchronous workers. The application will: Subscribe to around 20 different topics on Apache Kafka. Score some machine learning models with that data. Upload the results to a relational database. Each topic in Kafka will receive 1 message per minute, so the application needs to consume around 20 messages per minute from Kafka. For each message, the handling and execution take around 45 seconds. The question is how I can scale this in a good way? I know that I can add multiple workers in

how to run gunicorn on docker

蹲街弑〆低调 提交于 2019-12-06 01:41:24
问题 I have 2 files that depend on each other when docker is start up. 1 is a flask file and one is a file with a few functions. When docker starts, only the functions file will be executed but it imports flask variables from the flask file. Example: Flaskfile import flask from flask import Flask, request import json _flask = Flask(__name__) @_flask.route('/', methods = ['POST']) def flask_main(): s = str(request.form['abc']) ind = global_fn_main(param1,param2,param3) return ind def run(fn_main):

Run startup code in the parent with Django and Gunicorn

我与影子孤独终老i 提交于 2019-12-06 01:01:01
I need my code run at Django application startup, before Django starts listening for incoming connections. Running my code upon the first HTTP request is not good enough. When I use Gunicorn, my code must run in the parent process, before it forks. https://stackoverflow.com/a/2781488/97248 doesn't seem to work in Django 1.4.2: it doesn't run the Middleware's __init__ method until the first request is received. Ditto for adding code to urls.py . A quick Google search didn't reveal anything useful. I have just run into this problem myself, and the solution was to basically chain the commands to

gunicorn on heroku: binding to localhost

孤者浪人 提交于 2019-12-06 00:29:10
I've been following the tutorial on https://devcenter.heroku.com/articles/django#declare-process-types-with-procfile . It went smoothly except for one thing that bothers me. After starting foreman I should see the following: $ foreman start 2013-04-03 16:11:22 [8469] [INFO] Starting gunicorn 0.17.2 2013-04-03 16:11:22 [8469] [INFO] Listening at: http://127.0.0.1:8000 (8469) However, I get: Starting gunicorn 17.5 Listening at: http://0.0.0.0:5000 How can I change it so that it listens only to my local machine (ie. 127.0.0.1)? My Procfile contains only web: gunicorn hellodjango.wsgi thanks! This