# HG changeset patch # User Mads Kiilerich # Date 2020-04-05 17:09:45 # Node ID 7dbdb498f460ce306878be0b8171a288ed192709 # Parent 7fe5fccbbb1fa0a06df3c34b3bb521ed7dc144ae uwsgi: slim down and tweak the default '[uwsgi]' configuration section The goal is to have a basic working setup that show how and why to use uWSGI. System administrators should check uWSGI documentation for further information and general advice about operations. Based on uWSGI documentation, experiments, and https://www.techatbloomberg.com/blog/configuring-uwsgi-production-deployment/ . diff --git a/kallithea/lib/paster_commands/template.ini.mako b/kallithea/lib/paster_commands/template.ini.mako --- a/kallithea/lib/paster_commands/template.ini.mako +++ b/kallithea/lib/paster_commands/template.ini.mako @@ -111,64 +111,29 @@ timeout = 3600 %endif %else: <%text>## UWSGI ## -<%text>## run with uwsgi --ini-paste-logged [uwsgi] -socket = /tmp/uwsgi.sock -master = true -http-socket = ${host}:${port} - -<%text>## set as daemon and redirect all output to file -#daemonize = ./uwsgi_kallithea.log - -<%text>## master process PID -pidfile = ./uwsgi_kallithea.pid +<%text>## Note: this section is parsed by the uWSGI .ini parser when run as: +<%text>## uwsgi --venv /srv/kallithea/venv --ini-paste-logged my.ini -<%text>## stats server with workers statistics, use uwsgitop -<%text>## for monitoring, `uwsgitop 127.0.0.1:1717` -stats = 127.0.0.1:1717 -memory-report = true - -<%text>## log 5XX errors -log-5xx = true - -<%text>## Set the socket listen queue size. -listen = 128 - -<%text>## Gracefully Reload workers after the specified amount of managed requests -<%text>## (avoid memory leaks). -max-requests = 1000 +# HTTP Basics: +http-socket = ${host}:${port} +buffer-size = 65535 ; Mercurial will use huge GET headers for discovery -<%text>## enable large buffers -buffer-size = 65535 - -<%text>## socket and http timeouts ## -http-timeout = 3600 -socket-timeout = 3600 - -<%text>## Log requests slower than the specified number of milliseconds. -log-slow = 10 - -<%text>## Exit if no app can be loaded. -need-app = true - -<%text>## Set lazy mode (load apps in workers instead of master). -lazy = true +# Scaling: +master = true ; Use separate master and worker processes +auto-procname = true ; Name worker processes accordingly +lazy = true ; App *must* be loaded in workers - db connections can't be shared +workers = 4 ; On demand scaling up to this many worker processes +cheaper = 1 ; Initial and on demand scaling down to this many worker processes +max-requests = 1000 ; Graceful reload of worker processes to avoid leaks -<%text>## scaling ## -<%text>## set cheaper algorithm to use, if not set default will be used -cheaper-algo = spare - -<%text>## minimum number of workers to keep at all times -cheaper = 1 - -<%text>## number of workers to spawn at startup -cheaper-initial = 1 - -<%text>## maximum number of workers that can be spawned -workers = 4 - -<%text>## how many workers should be spawned at a time -cheaper-step = 1 +# Tweak defaults: +strict = true ; Fail on unknown config directives +enable-threads = true ; Enable Python threads (not threaded workers) +vacuum = true ; Delete sockets during shutdown +single-interpreter = true +die-on-term = true ; Shutdown when receiving SIGTERM (default is respawn) +need-app = true ; Exit early if no app can be loaded. %endif <%text>## middleware for hosting the WSGI application under a URL prefix