"""
Gunicorn WSGI server configuration for production deployment
"""
import multiprocessing

# Server socket
bind = '127.0.0.1:8000'
backlog = 2048

# Worker processes
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = 'sync'
worker_connections = 1000
timeout = 30
keepalive = 2

# Process naming
proc_name = 'aibimagics_ecommerce'

# Server mechanics
daemon = False
pidfile = '/var/www/aibimagics/gunicorn.pid'
user = None
group = None
tmp_upload_dir = None

# Logging
accesslog = '/var/www/aibimagics/logs/gunicorn-access.log'
errorlog = '/var/www/aibimagics/logs/gunicorn-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
pythonpath = '/var/www/aibimagics'

# SSL (if using Gunicorn for SSL, though Nginx is recommended)
# keyfile = '/path/to/keyfile'
# certfile = '/path/to/certfile'

# Server hooks
def on_starting(server):
    print("Gunicorn server is starting...")

def on_reload(server):
    print("Gunicorn server is reloading...")

def when_ready(server):
    print("Gunicorn server is ready. Spawning workers")

def on_exit(server):
    print("Gunicorn server is shutting down...")
