-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy path.env.example
More file actions
92 lines (83 loc) · 3.13 KB
/
.env.example
File metadata and controls
92 lines (83 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# =================================================================
# BrowserCluster 环境变量配置文件示例
# 使用方法:复制此文件并重命名为 .env,然后根据实际情况修改配置
# =================================================================
# -----------------------------------------------------------------
# 1. FastAPI 基础配置
# -----------------------------------------------------------------
APP_NAME=BrowserCluster
APP_VERSION=1.0.0
DEBUG=True
HOST=0.0.0.0
PORT=8000
# -----------------------------------------------------------------
# 2. 数据库与缓存配置
# -----------------------------------------------------------------
# MongoDB: 用于存储抓取结果等大规模数据
MONGO_URI=mongodb://localhost:27017/
MONGO_DB=browser_cluster
# Redis: 用于任务状态追踪与缓存
# 队列使用的 Redis (db 0)
REDIS_URL=redis://localhost:6379/0
# 缓存使用的 Redis (db 1)
REDIS_CACHE_URL=redis://localhost:6379/1
# -----------------------------------------------------------------
# 3. 消息队列配置 (RabbitMQ)
# -----------------------------------------------------------------
RABBITMQ_URL=amqp://guest:guest@localhost:5672/
RABBITMQ_QUEUE=scrape_tasks
RABBITMQ_EXCHANGE=browser_cluster
# -----------------------------------------------------------------
# 4. Playwright 浏览器引擎配置
# -----------------------------------------------------------------
# 浏览器类型: chromium, firefox, webkit
BROWSER_TYPE=chromium
# 是否使用无头模式
HEADLESS=True
# 隐蔽模式 (防止被检测)
STEALTH_MODE=True
# 拦截资源
BLOCK_IMAGES=False
BLOCK_MEDIA=False
# 超时与等待策略
DEFAULT_TIMEOUT=30000
DEFAULT_WAIT_FOR=networkidle
# 默认视口尺寸
DEFAULT_VIEWPORT_WIDTH=1920
DEFAULT_VIEWPORT_HEIGHT=1080
# 默认 User-Agent
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36"
# 浏览器空闲自动关闭时间 (秒)
BROWSER_IDLE_TIMEOUT=300
# -----------------------------------------------------------------
# 5. Worker 与 节点配置
# -----------------------------------------------------------------
# Worker 并发处理任务数
WORKER_CONCURRENCY=3
# 任务重试机制
MAX_RETRIES=3
RETRY_DELAY=5
# 节点标识
NODE_ID=node-1
NODE_TYPE=worker
HEARTBEAT_INTERVAL=30
MAX_NODE_AUTO_RETRIES=5
# -----------------------------------------------------------------
# 6. 缓存机制配置
# -----------------------------------------------------------------
CACHE_ENABLED=True
DEFAULT_CACHE_TTL=3600
# -----------------------------------------------------------------
# 7. 安全与身份验证配置
# -----------------------------------------------------------------
# 建议在生产环境中使用复杂的随机字符串: openssl rand -hex 32
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
# Token 有期效时间 (分钟),默认 24 小时
ACCESS_TOKEN_EXPIRE_MINUTES=1440
# -----------------------------------------------------------------
# 8. 日志配置
# -----------------------------------------------------------------
# 日志级别: DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL=INFO
LOG_FILE=logs/app.log