FIX: Add Gunicorn config variables to gunicorn_app.py - 1764916965
Browse files
hue_portal/hue_portal/gunicorn_app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
"""
|
| 2 |
Gunicorn application wrapper with post_fork hook for model preloading.
|
|
|
|
| 3 |
"""
|
| 4 |
import os
|
| 5 |
import sys
|
|
@@ -14,7 +15,7 @@ django.setup()
|
|
| 14 |
# Import wsgi application
|
| 15 |
from hue_portal.hue_portal.wsgi import application
|
| 16 |
|
| 17 |
-
# Define post_fork hook
|
| 18 |
def post_fork(server, worker):
|
| 19 |
"""Called when worker process is forked - preload models here."""
|
| 20 |
print(f'[GUNICORN] 🔔 Worker {worker.pid} forked, preloading models...', flush=True)
|
|
@@ -26,6 +27,8 @@ def post_fork(server, worker):
|
|
| 26 |
import traceback
|
| 27 |
traceback.print_exc()
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
Gunicorn application wrapper with post_fork hook for model preloading.
|
| 3 |
+
This file serves as both the WSGI application and Gunicorn config.
|
| 4 |
"""
|
| 5 |
import os
|
| 6 |
import sys
|
|
|
|
| 15 |
# Import wsgi application
|
| 16 |
from hue_portal.hue_portal.wsgi import application
|
| 17 |
|
| 18 |
+
# Define post_fork hook (Gunicorn will call this automatically)
|
| 19 |
def post_fork(server, worker):
|
| 20 |
"""Called when worker process is forked - preload models here."""
|
| 21 |
print(f'[GUNICORN] 🔔 Worker {worker.pid} forked, preloading models...', flush=True)
|
|
|
|
| 27 |
import traceback
|
| 28 |
traceback.print_exc()
|
| 29 |
|
| 30 |
+
# Gunicorn config variables
|
| 31 |
+
bind = "0.0.0.0:7860"
|
| 32 |
+
timeout = 1800
|
| 33 |
+
graceful_timeout = 1800
|
| 34 |
+
worker_class = "sync"
|