diff --git a/run.py b/run.py index 61c2939ff..76602e44f 100644 --- a/run.py +++ b/run.py @@ -2,14 +2,10 @@ from pychunkedgraph.app import create_app application = create_app() - +print("running default app") if __name__ == "__main__": - WSGIRequestHandler.protocol_version = "HTTP/1.1" - application.run(host='0.0.0.0', - port=80, - debug=False, - threaded=True, - ssl_context='adhoc') - + application.run( + host="0.0.0.0", port=80, debug=False, threaded=True, ssl_context="adhoc" + ) diff --git a/uwsgi_read.ini b/uwsgi_read.ini new file mode 100644 index 000000000..9ef790341 --- /dev/null +++ b/uwsgi_read.ini @@ -0,0 +1,114 @@ +[uwsgi] +socket = /tmp/uwsgi.sock +chown-socket = nginx:nginx +chmod-socket = 664 +# Graceful shutdown on SIGTERM, see https://github.com/unbit/uwsgi/issues/849#issuecomment-118869386 +hook-master-start = unix_signal:15 gracefully_kill_them_all + +module = run +callable = application + +uid = nginx +gid = nginx + +env = HOME=/home/nginx + +# Python venv +if-env = VIRTUAL_ENV +virtualenv = %(_) +endif = + +### Worker scaling +# maximum number of workers +processes = 180 + +# https://uwsgi-docs.readthedocs.io/en/latest/Cheaper.html#busyness-cheaper-algorithm +cheaper-algo = busyness + +# Time window for tracking average busyness +cheaper-overload = 20 + +# Number of idle cycles before stopping a worker +cheaper-busyness-multiplier = 3 + +# Minimum number of workers +cheaper = 50 + +# Start with 8 workers +cheaper-initial = 50 + +# Spawn at most 8 workers at once +cheaper-step = 50 + +# Start spawning more workers at 60% busyness +cheaper-busyness-max = 60 + +# Start killing workers if busyness falls below 20% +cheaper-busyness-min = 20 + + +### Reloads and limitations +# max socket listen queue length - requires net.somaxconn increase +listen = 32768 + +# Max request header size +buffer-size = 65535 + +# Don't spawn new workers if total memory over 6 GiB +cheaper-rss-limit-soft = 6442450944 + +# Reload worker after serving X requests +max-requests = 5000 + +# Grace period for single worker to reload/shutdown +worker-reload-mercy = 600 + +# Grace period for all workers and processes to reload/shutdown +reload-mercy = 605 + +# Kill stuck/unresponsive processes after 20 minutes +harakiri = 1200 + + +### Misc +# Maintain Python thread support +enable-threads = true + +# Required for cheaper-rss-limit-soft +memory-report = true + +# Additional log output for harakiri +harakiri-verbose = true + + +### Logging +# Filter our properly pre-formated app messages and pass them through +logger = app stdio +log-route = app ^{.*"source":.*}$ + +# Capture known / most common uWSGI messages +logger = uWSGIdebug stdio +logger = uWSGIwarn stdio + +log-route = uWSGIdebug ^{address space usage +log-route = uWSGIwarn \[warn\] + +log-encoder = json:uWSGIdebug {"source":"uWSGI","time":"${strftime:%Y-%m-%dT%H:%M:%S.000Z}","severity":"debug","message":"${msg}"} +log-encoder = nl:uWSGIdebug +log-encoder = json:uWSGIwarn {"source":"uWSGI","time":"${strftime:%Y-%m-%dT%H:%M:%S.000Z}","severity":"warning","message":"${msg}"} +log-encoder = nl:uWSGIwarn + +# Treat everything else as error message of unknown origin +logger = unknown stdio + +# Creating our own "inverse Regex" using negative lookaheads, which makes this +# log-route rather cryptic and slow... Unclear how to get a simple +# "fall-through" behavior for non-matching messages, otherwise. +log-route = unknown ^(?:(?!^{address space usage|\[warn\]|^{.*"source".*}$).)*$ + +log-encoder = json:unknown {"source":"unknown","time":"${strftime:%Y-%m-%dT%H:%M:%S.000Z}","severity":"error","message":"${msg}"} +log-encoder = nl:unknown + +log-4xx = true +log-5xx = true +disable-logging = true