gunicorn

How to use Flask-Script and Gunicorn

旧街凉风 提交于 2019-11-27 11:23:27
I'm working on on a Flask app using Flask's built in dev server. I start it using Flask-Script. I want to switch to using Gunicorn as the web server. To do so, do I need to write some sort of integration code between Flask-Script and Gunicorn? Or is Flask-Script irrelevant to running the app using Gunicorn? Thanks in advance! Props to @sean-lynch. The following is working, tested code based on his answer. The changes I made were: Options that aren't recognized by Gunicorn are removed from sys.argv in remove_non_gunicorn_command_line_args() before trying to start the server. Otherwise Gunicorn

How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku?

笑着哭i 提交于 2019-11-27 10:56:06
I'm new to heroku and gunicorn so I'm not sure how this works. But I've done some searching and I think I'm close to deploying my Django app (1.5.1). So I know I need a Procfile which has web: gunicorn app.wsgi Because my directories are a bit different. I can't run gunicorn in the root directory app_project requirements/ contributors/ app/ app/ settings/ wsgi.py # Normally Procfile goes here Procfile Normally app/ would be the root directory, but I decided to structure my folders this way to separate my django app from some other things. Since I have to put the Procfile in the root directory

Debugging a Flask app running in Gunicorn

拈花ヽ惹草 提交于 2019-11-27 10:27:30
I've been working on a new dev platform using nginx/gunicorn and Flask for my application. Ops-wise, everything works fine - the issue I'm having is with debugging the Flask layer. When there's an error in my code, I just get a straight 500 error returned to the browser and nothing shows up on the console or in my logs. I've tried many different configs/options.. I guess I must be missing something obvious. My gunicorn.conf: import os bind = '127.0.0.1:8002' workers = 3 backlog = 2048 worker_class = "sync" debug = True proc_name = 'gunicorn.proc' pidfile = '/tmp/gunicorn.pid' logfile = '/var

What is the correct way to leave gunicorn running?

一笑奈何 提交于 2019-11-27 09:59:44
问题 I want to make a Flask+Nginx+Gunicorn deployment. I have Nginx setup and running and I run gunicorn as described in the docs: gunicorn app:app But when I logout of the server the gunicorn process exits? What is the correct way to make sure it stay running for Nginx to connect to, and restarts if it crashes? 回答1: I'd look into something like Supervisor. 回答2: Use --daemon option while running gunicorn. Example: gunicorn grand56.wsgi:application --name grand56 --workers 3 --user=root --group

Gunicorn Workers and Threads

安稳与你 提交于 2019-11-27 09:22:12
问题 In terms of Gunicorn, I am aware there are various worker classes but for this conversation I am just looking at the sync and async types. From my understanding ... sync workers = (2 * cpu) + 1 worker_class = sync async (gevent) workers = 1 worker_class = gevent worker_connections = a value (lets say 2000) So (based on a 4 core system) using sync workers I can have a maximum of 9 connections processing in parallel. With Async I can have up to 2000, with the caveats that come with async.

Deploying Django with gunicorn and nginx

左心房为你撑大大i 提交于 2019-11-27 09:09:51
问题 This is a broad question but I'd like to get a canonical answer. I have been trying to deploy a site using gunicorn and nginx in Django . After reading tons of tutorials I have been successful but I can't be sure that the steps I followed are good enough to run a site without problems or maybe there are better ways to do it. That uncertainty is annoying. That's why I'm looking for a very detailed and well explained answer for newbies. I don't want to explain too much what I know and what I

504 error when the view loading takes more than 5 s

旧巷老猫 提交于 2019-11-27 08:48:07
问题 I've got an installation with django-nginx-gunicorn-supervisor-postgresql . In the Django admin, I've got a 504 if the loading of the view takes more than around 5 seconds. For instance, if I filter a change list view with many records and takes more than that time, the 504 appears. The same view with fewer records works, as long as it takes less time. I've noticed also that some views are still running in the background, even after the 504, cause I can see the modifications they make in the

Errno 13 Permission denied using Gunicorn

Deadly 提交于 2019-11-27 06:55:45
问题 I'm running django on Digital Ocean with gunicorn and nginx . Gunicorn for serving the django and nginx for static files. Upon uploading a file via website, I cant save to a folder in /home directory. I get [Errno 13] Permission denied. Please, how do I make the web server to be able have read write access to any arbitrary folder anywhere under /home? 回答1: This all depends on the user that your application is running as. If you check ps aux | grep gunicorn which user the Gunicorn server is

How to make Django serve static files with Gunicorn?

只愿长相守 提交于 2019-11-27 06:22:52
I want to run my django project under gunicorn on localhost. I installed and integrated gunicorn. When I run: python manage.py run_gunicorn It works but there are no any static files (css and js) I disabled debug and template_debug in settings.py (made them false), but it is still same. Am I missing something? I call statics like: {{ STATIC_URL }}css/etc.... When in development mode and when you are using some other server for local development add this to your url.py from django.contrib.staticfiles.urls import staticfiles_urlpatterns # ... the rest of your URLconf goes here ... urlpatterns +=

Flask Gunicorn app can't get __name__ to equal '__main__'

◇◆丶佛笑我妖孽 提交于 2019-11-27 05:28:38
I have this from /home/myname/myapp/app.py : from flask import Flask app = Flask(__name__) print __name__ @app.route('/') def index(): return "Hello world!" if __name__ == '__main__': print 'in if' app.run() When I run: $ gunicorn app:app -b 127.0.0.2:8000 It says: 2013-03-01 11:26:56 [21907] [INFO] Starting gunicorn 0.17.2 2013-03-01 11:26:56 [21907] [INFO] Listening at: http://127.0.0.2:8000 (21907) 2013-03-01 11:26:56 [21907] [INFO] Using worker: sync 2013-03-01 11:26:56 [21912] [INFO] Booting worker with pid: 21912 app So the __name__ of the app is app . Not __main__ like I need it to be