From 3b464983ce66a4137aed130b7acfd7c561c04003 Mon Sep 17 00:00:00 2001 From: Piotr Dec Date: Tue, 7 Apr 2026 23:00:24 +0200 Subject: [PATCH] feat: gunicorn config --- systemd/gunicorn.conf.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 systemd/gunicorn.conf.py diff --git a/systemd/gunicorn.conf.py b/systemd/gunicorn.conf.py new file mode 100644 index 0000000..3cdca6b --- /dev/null +++ b/systemd/gunicorn.conf.py @@ -0,0 +1,29 @@ +# Gunicorn configuration for FastAPI +import multiprocessing + +# Server socket +bind = "127.0.0.1:8000" +backlog = 2048 + +# Worker processes +# Rule of thumb: (2 * CPU cores) + 1 +workers = multiprocessing.cpu_count() * 2 + 1 +worker_class = "uvicorn.workers.UvicornWorker" +worker_connections = 1000 +timeout = 30 +keepalive = 2 + +# Logging +accesslog = "/var/log/karl/access.log" +errorlog = "/var/log/karl/error.log" +loglevel = "info" +access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %(D)s' + +# Process naming +proc_name = "karl" + +# Graceful shutdown +graceful_timeout = 30 + +# Preload app for faster worker spawning +preload_app = True