gunicorn

Django's caching middleware not working in Gunicorn with Debug=False

那年仲夏 提交于 2019-12-24 10:49:54
问题 I have a Django project deployed with Gunicorn and nginx. I also have a memcached running and the Django cache middleware () set up to cache the site. Everything works fine when running with DEBUG=True, but when I switch to DEBUG=False I get the following error in Gunicorn log when trying to access the site: 2013-02-20 16:09:50 [25196] [ERROR] Error handling request Traceback (most recent call last): File "/home/toursprung/.virtualenvs/myproject/lib/python2.6/site-packages/gunicorn/workers

How to serve media file using Nginx and django?

删除回忆录丶 提交于 2019-12-24 10:15:02
问题 Good evening, I am currently facing an issue on my home project. I set up a django project, with gunicorn and nginx. Nginx seems to serve my statics normally but when it comes to media files it does not work and i have the following message displayed in my error log: failed (2: No such file or directory) I tried to use different users for nginx.conf but it is still the same. I am missing something somewhere but i can not find out. I attach my nginx file (updated): upstream app_server { server

Heroku flask deployment issue - logs shows gunicorn: error: unrecognized arguments: app:app

一个人想着一个人 提交于 2019-12-24 09:58:06
问题 We have a small flask project here https://github.com/codesydney/OPEND It is working as expected locally. However, when deployed to heroku, it keeps on throwing gunicorn: error: unrecognized arguments: app:app. Procfile content is "web: gunicorn app:app". Thanks in advance for your help. Cheers! 回答1: Your should write in your procfile this: web: gunicorn run:app Leftside argument is a name of the app that will be launched. In your case it's run.py. 来源: https://stackoverflow.com/questions

Gunicorn can't find staticfiles after dockerization

夙愿已清 提交于 2019-12-24 06:34:54
问题 I am using docker 17.05.0-cs edge on Ubuntu 17.04 Zesty. I have a gunicorn/Django app that I built here. It runs fine before being dockerized, but gunicorn can't see the staticfiles after docker build . Here is the Dockerfile : # Dockerfile # FROM base image to build upon FROM phusion/baseimage # RUN install python and pip RUN apt-get update RUN apt-get install -y python python-pip python-dev # ENV set environment directory tree ENV PROJECT=mysite ENV CONTAINER_HOME=/opt ENV CONTAINER_PROJECT

How can I start an asynchronous function in Flask / gunicorn / gevent?

余生颓废 提交于 2019-12-24 03:56:11
问题 I currently have a Flask application from flask import Flask import time app = Flask(__name__) @app.route('/') def foobar_view(): long_running() # TODO: Just trigger this; don't wait for completion return 'Done!' def long_running(): print('long_running:start') time.sleep(100) print('long_running:end') app.run(host='localhost', port=5000) started with gunicorn --worker-class=gevent \ --worker-connections=1000 \ --bind 0.0.0.0:5000 my_app.app:app \ --workers=4 \ --timeout 120 \ --keep-alive 120

Why is auto-reload on code change only for debugging with Gunicorn?

Deadly 提交于 2019-12-24 02:58:30
问题 I'm using Gunicorn to run my Flask website in production. It all works fine, but when deploying updates I always stop and start the server again. I now read about this reload flag which "restarts workers when code changes" which according to the docs is " intended for development ". If I could use this in production it would prevent the need to stop & restart gunicorn when deploying. What is the reason that I should not use auto-reload in production? 回答1: The reload flag can be used in

Serve a Bottle application from gunicorn on Heroku?

你离开我真会死。 提交于 2019-12-24 02:56:21
问题 Procfile web: python server.py server.py from os import environ from bottle import app, route, run, static_file @route('/') def root(): return "Hello world!" if __name__ == '__main__': run(server='gunicorn', host='0.0.0.0', port=int(environ.get("PORT", 5000))) requirements.txt gunicorn psycopg2 git+https://github.com/defnull/bottle#egg=bottle Relevant portion of logfile (after git push ) heroku[router]: at=error code=H14 desc="No web processes running" 回答1: First of all: Are you certain that

How to share dictionary between gunicorn processes?

萝らか妹 提交于 2019-12-24 01:58:15
问题 I have a server code with a global dictionary variable. It works nice with a single process gunicorn but it got errors when I make it multiprocesses since one values are not reach in this dictionary. I believe it is because this dictionary cannot be shared between processes. Do you know any workaround for this kind of a problem? 回答1: I'm sorry to say that if you're trying to access to a shared python object between different instances from Gunicorn workers (gevent for example) you'll need to

How to filter logs from gunicorn?

北战南征 提交于 2019-12-24 00:42:48
问题 I have a Flask API with gunicorn. Gunicorn logs all the requests to my API, i.e. 172.17.0.1 - - [19/Sep/2018:13:50:58 +0000] "GET /api/v1/myview HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" However, I want to filter the logs to exclude a certain endpoint which is called from some other service all few seconds. I wrote a filter to exclude this endpoint from being logged: class NoReadyFilter

Django site not accessible after gunicorn started

与世无争的帅哥 提交于 2019-12-23 23:17:36
问题 I'm trying to start a gunicorn server with a shell script. The problem is that a site is not accessible (connection times out when I try to access it via browser). I have here 2 scripts, one which works and one which doesn't. I'm trying to understand why the first script doesn't work and how to fix the problem. First sript ( doesn't work ; connection timeout when I try to access the site at domain.com:8000; no errors in the logs): #!/bin/bash set -e LOGFILE=/var/log/gunicorn/hello.log LOGDIR=