Last active
April 11, 2017 08:28
-
-
Save Shellbye/882a262f706f42c326dddc8441bbc55d to your computer and use it in GitHub Desktop.
uwsgi zero downtime restart config Zerg Dance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nginx.conf | |
# the upstream component nginx needs to connect to | |
upstream my_project { | |
server 127.0.0.1:3031 | |
} | |
# configuration of the server | |
server { | |
# the port your site will be served on | |
listen 8082; | |
# the domain name it will serve for | |
charset utf-8; | |
# max upload size | |
client_max_body_size 200M; # adjust to taste | |
location / { | |
uwsgi_pass my_project; | |
include /etc/nginx/uwsgi_params; | |
uwsgi_read_timeout 300; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uwsgi ini file | |
[uwsgi] | |
# http://stackoverflow.com/questions/14194859/importerror-no-module-named-django-core-wsgi-for-uwsgi | |
project_name = my_app | |
# Django-related settings | |
# the base directory (full path) | |
chdir = %d | |
# the absolute path of the directory containing the configuration file | |
# http://uwsgi-docs.readthedocs.io/en/latest/Configuration.html | |
# %n the filename without extension | |
# process-related settings | |
# master | |
module = app | |
;master = true | |
# maximum number of worker processes | |
# adjust according to http://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html | |
processes = 10 | |
max-requests = 15 | |
# the socket (use the full path to be safe | |
;socket = /tmp/%(project_name).sock | |
# ... with appropriate permissions - may be needed | |
chmod-socket = 666 | |
#chown-socket = www-data:www-data | |
# clear environment on exit | |
vacuum = true | |
daemonize = /tmp/%(project_name).log | |
pidfile = /tmp/%(project_name).pid | |
# added 2014-08-25 | |
#emperor = /etc/uwsgi/vassals | |
#uid = www-data | |
#gid = www-data | |
# added 2014-09-17 | |
reload-on-as = 126 | |
reload-on-rss = 126 | |
enable-threads = true | |
pythonpath = %d | |
# the absolute path of the directory containing the configuration file | |
env = LANG=en_US.UTF-8 | |
# http://stackoverflow.com/questions/10396141/strange-unicodeencodeerror-using-os-path-exists | |
stats = /tmp/%(project_name)_stats.sock | |
; fifo '0' | |
master-fifo = /var/run/new.fifo | |
; fifo '1' | |
master-fifo = /var/run/running.fifo | |
; fifo '2' | |
master-fifo = /var/run/sleeping.fifo | |
; attach to zerg | |
zerg = /var/run/pool1 | |
; hooks | |
; destroy the currently sleeping instance | |
if-exists = /var/run/sleeping.fifo | |
hook-accepting1-once = writefifo:/var/run/sleeping.fifo Q | |
endif = | |
; force the currently running instance to became sleeping (slot 2) and place it in pause mode | |
if-exists = /var/run/running.fifo | |
hook-accepting1-once = writefifo:/var/run/running.fifo 2p | |
endif = | |
; force this instance to became the running one (slot 1) | |
hook-accepting1-once = writefifo:/var/run/new.fifo 1 | |
# destroy the running instance | |
# echo Q > /var/run/running.fifo | |
# unpause the sleeping instance and set it as the running one | |
# echo p2 > /var/run/sleeping.fifo | |
[uwsgi-m] | |
master = true | |
zerg-pool = /var/run/pool1:127.0.0.1:3031 | |
daemonize = /tmp/uwsgi_master.log | |
pidfile = /tmp/uwsgi_master.pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref
http://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html
http://zarnovican.github.io/2016/02/15/uwsgi-graceful-reload/
http://daniellombrana.es/blog/2015/07/01/gracefulreloading.html