prod deploy version

This commit is contained in:
OwusuBlessing
2025-06-11 17:40:17 +01:00
parent 3fcce3b464
commit 3bd6213a8d
6 changed files with 306 additions and 219 deletions
+77
View File
@@ -0,0 +1,77 @@
import multiprocessing
import os
# Server socket
bind = "0.0.0.0:5042" # Same port as in your app.py
backlog = 2048
# Worker processes
workers = multiprocessing.cpu_count() * 2 + 1 # Recommended formula for worker count
worker_class = "uvicorn.workers.UvicornWorker" # Required for FastAPI
worker_connections = 1000
timeout = 30
keepalive = 2
# Logging
accesslog = "logs/access.log"
errorlog = "logs/error.log"
loglevel = "info"
# Process naming
proc_name = "fire_fighter_api"
# SSL (uncomment and configure if using HTTPS)
# keyfile = "path/to/keyfile"
# certfile = "path/to/certfile"
# Server mechanics
daemon = False
pidfile = "gunicorn.pid"
umask = 0
user = None
group = None
tmp_upload_dir = None
# Server hooks
def on_starting(server):
"""
Server startup hook
"""
# Create logs directory if it doesn't exist
os.makedirs("logs", exist_ok=True)
def post_fork(server, worker):
"""
Worker initialization hook
"""
server.log.info("Worker spawned (pid: %s)", worker.pid)
def pre_fork(server, worker):
"""
Pre-fork hook
"""
pass
def pre_exec(server):
"""
Pre-exec hook
"""
server.log.info("Forked child, re-executing.")
def when_ready(server):
"""
Server ready hook
"""
server.log.info("Server is ready. Spawning workers")
def worker_int(worker):
"""
Worker interrupt hook
"""
worker.log.info("worker received INT or QUIT signal")
def worker_abort(worker):
"""
Worker abort hook
"""
worker.log.info("worker received SIGABRT signal")