Skip to content

Commit 2444e9a

Browse files
author
RSSHub-Py
committed
feat: Set up Gunicorn configuration for production with specific worker, thread, and timeout settings, and suppress Flask deprecation warning.
1 parent 4507adf commit 2444e9a

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ uv run flask run
7777
### Production Environment
7878

7979
```bash
80-
uv run gunicorn main:app -b 0.0.0.0:5000
80+
uv run gunicorn -c gunicorn.conf main:app
8181
```
8282

8383
### Deploy to Vercel

gunicorn.conf

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
[program:gunicorn]
2-
command=/usr/local/bin/gunicorn main:app -b localhost:5000
3-
directory=/app
1+
# Gunicorn configuration file
2+
import multiprocessing
3+
4+
# Bind to all interfaces on port 5000
5+
bind = "0.0.0.0:5000"
6+
7+
# Worker Options
8+
# Using 1 worker to maintain shared memory cache (SimpleCache) consistency
9+
workers = 1
10+
# Use threads for concurrency within the single worker
11+
threads = 4
12+
13+
# Timeout
14+
# Increased to 120 seconds to accommodate long-running scrapers (e.g., Economist)
15+
timeout = 120
16+
17+
# Logging
18+
accesslog = "-" # Log to stdout
19+
errorlog = "-" # Log to stderr
20+
loglevel = "info"

main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import warnings
2+
# Suppress pkg_resources deprecation warning from Flask 2.0.2
3+
warnings.filterwarnings("ignore", category=UserWarning, module="flask.cli")
4+
15
import os
26
from dotenv import load_dotenv
37

0 commit comments

Comments
 (0)