zpsajst commited on
Commit
4de72c5
·
1 Parent(s): c3ffb3f

Production fix: Add Gunicorn with 300s timeout for HuggingFace Spaces stability

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -2
  2. requirements.txt +1 -0
Dockerfile CHANGED
@@ -34,5 +34,5 @@ ENV PYTHONUNBUFFERED=1
34
  ENV TRANSFORMERS_CACHE=/app/models_cache
35
  ENV HF_HOME=/app/models_cache
36
 
37
- # Run the application
38
- CMD ["python", "combined_server.py"]
 
34
  ENV TRANSFORMERS_CACHE=/app/models_cache
35
  ENV HF_HOME=/app/models_cache
36
 
37
+ # Run with Gunicorn for production stability and timeout handling
38
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "300", "--graceful-timeout", "300", "--keep-alive", "5", "combined_server:app"]
requirements.txt CHANGED
@@ -4,6 +4,7 @@
4
  # Core Framework
5
  flask==2.3.0
6
  flask-cors==4.0.0
 
7
 
8
  # HTTP & Web Scraping
9
  requests==2.31.0
 
4
  # Core Framework
5
  flask==2.3.0
6
  flask-cors==4.0.0
7
+ gunicorn==21.2.0
8
 
9
  # HTTP & Web Scraping
10
  requests==2.31.0