# Gunicorn configuration for production
import multiprocessing

# Server socket
bind = "127.0.0.1:8080"
backlog = 2048

# Worker processes
workers = 2  # Optimized for shared server (2 CPU cores allocated)
worker_class = "sync"
worker_connections = 1000
timeout = 120  # Increased to handle slow DB queries
keepalive = 5
graceful_timeout = 30  # Time to finish requests before force shutdown

# Logging
accesslog = "/media/pts/Website/Church_HOP_MusicData/backend/logs/access.log"
errorlog = "/media/pts/Website/Church_HOP_MusicData/backend/logs/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"'

# Process naming
proc_name = "church_music_backend"

# Server mechanics
daemon = False
pidfile = None  # No pidfile needed for systemd management
umask = 0
user = None
group = None
tmp_upload_dir = None

# SSL (if needed later)
# keyfile = None
# certfile = None
