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