fmab777 commited on
Commit
fe9e418
·
verified ·
1 Parent(s): c01c425

Update gunicorn.conf.py

Browse files
Files changed (1) hide show
  1. gunicorn.conf.py +27 -4
gunicorn.conf.py CHANGED
@@ -1,11 +1,34 @@
1
  # gunicorn.conf.py
2
  import os
 
3
 
 
 
 
 
 
4
  worker_class = 'uvicorn.workers.UvicornWorker'
 
 
 
 
5
  workers = int(os.environ.get('GUNICORN_WORKERS', '1'))
6
- bind = f"0.0.0.0:{os.environ.get('PORT', '7860')}"
7
 
8
- # Timeout should be longer than the longest expected API call (e.g., OpenRouter 180s)
9
- timeout = 200 # 200 seconds
 
 
 
 
 
 
 
 
10
 
11
- # loglevel = 'info'
 
 
 
 
 
 
 
1
  # gunicorn.conf.py
2
  import os
3
+ import multiprocessing
4
 
5
+ # Hugging Face standard port
6
+ _port = os.environ.get('PORT', '7860')
7
+ bind = f"0.0.0.0:{_port}"
8
+
9
+ # Worker class for ASGI
10
  worker_class = 'uvicorn.workers.UvicornWorker'
11
+
12
+ # Number of workers - Use GUNICORN_WORKERS env var, default to a sensible value
13
+ # Default to 1 for safety on potentially small free tier instances
14
+ # You might increase this based on available CPU/Memory: min(multiprocessing.cpu_count() * 2 + 1, 4)
15
  workers = int(os.environ.get('GUNICORN_WORKERS', '1'))
 
16
 
17
+ # Timeout - needs to be longer than the longest expected scrape/summary task
18
+ # Includes crawl4ai timeout + summary timeout + buffer
19
+ # Crawl4AI default is 60s, Gemini/OpenRouter can take 90-120s. Let's set to 240s.
20
+ timeout = 240 # seconds
21
+
22
+ # Optional: Log level (can also be set via env var)
23
+ # loglevel = os.environ.get('GUNICORN_LOGLEVEL', 'info').lower()
24
+
25
+ # Optional: Reload for development (usually False in production)
26
+ # reload = os.environ.get('GUNICORN_RELOAD', 'False').lower() == 'true'
27
 
28
+ print(f"Gunicorn config:")
29
+ print(f" Bind: {bind}")
30
+ print(f" Workers: {workers}")
31
+ print(f" Worker Class: {worker_class}")
32
+ print(f" Timeout: {timeout}s")
33
+ # print(f" Log Level: {loglevel}")
34
+ # print(f" Reload: {reload}")