美团券 ETL:运行锁改用 /tmp(摆脱 data/ 的 root 权限依赖)+ 新增定时任务运维手册
- 锁文件默认改到系统临时目录(任何账号可写),支持 MEITUAN_ETL_LOCK 覆盖;修无 sudo 部署时 data/ 属 root → 每轮 PermissionError、cron 抓不进数据的问题 - 新增 deploy/meituan-etl.md:启动/关闭/终止/代码位置/健康检查/调频率/根因背景
This commit is contained in:
@@ -22,6 +22,7 @@ import hashlib
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
@@ -44,7 +45,10 @@ PAGE_SIZE = 20
|
||||
MAX_PAGES = 80 # 单路安全上限(搜索 ~52 页、供给 ~70 页)
|
||||
PAGE_SLEEP = 0.35 # 页间配速,缓解 402
|
||||
RETRY = 7
|
||||
LOCK_FILE = "data/.meituan_etl.lock"
|
||||
# 运行锁默认放系统临时目录(任何账号可写),不依赖代码目录 data/ 的写权限——
|
||||
# 无 sudo 部署时 data/ 常属 root,cps 写不了会导致每轮 PermissionError、cron 抓不进数据。
|
||||
# 需要指定位置时用环境变量 MEITUAN_ETL_LOCK 覆盖。
|
||||
LOCK_FILE = os.environ.get("MEITUAN_ETL_LOCK") or os.path.join(tempfile.gettempdir(), "meituan_etl.lock")
|
||||
LOCK_STALE_SEC = 30 * 60 # 锁超过 30min 视为陈旧(进程异常退出残留),自动接管
|
||||
|
||||
SOURCES = [
|
||||
|
||||
Reference in New Issue
Block a user