Compare commits

...

1 Commits

Author SHA1 Message Date
marco e2fd864bdc chore(deploy): 美团券 ETL 定时任务 systemd unit(销量榜数据源)
把 scripts/pull_meituan_coupons.py 跑成定时任务,持续给 meituan_coupon
表灌数据(销量榜 /api/v1/meituan/top-sales 的数据源)。两个 unit:

- meituan-etl.service: oneshot,跑 `python -m scripts.pull_meituan_coupons
  --once --prune-hours 24`;EnvironmentFile 复用 .env 拿 MT_CPS 凭证 / DATABASE_URL
- meituan-etl.timer: OnActiveSec=1min(启用即跑,首次 1 分钟内)+
  OnUnitActiveSec=1h(之后每隔 1 小时)。不用 OnActiveSec=0——本机 systemd
  对 0 + OnUnitActiveSec 报 Result=resources 拒绝加载

已部署 ecs1(scp 到 /etc/systemd/system/ + enable --now),首轮 success、
top-sales 接口返回带销量排序数据。安装/运维说明见 docs 仓库的
运维/销量榜feed排序_变更与部署记录.md。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 04:05:05 +08:00
2 changed files with 28 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
[Unit]
Description=Shaguabijia Meituan CPS coupon ETL (灌 meituan_coupon 供销量/佣金排序)
After=network-online.target postgresql.service
Wants=network-online.target
[Service]
Type=oneshot
User=root
WorkingDirectory=/opt/shaguabijia-app-server
# 复用 app-server 的 .env(MT_CPS 凭证 / DATABASE_URL),与 shaguabijia-app-server.service 同源
EnvironmentFile=/opt/shaguabijia-app-server/.env
Environment=PYTHONUNBUFFERED=1
ExecStart=/opt/shaguabijia-app-server/.venv/bin/python -m scripts.pull_meituan_coupons --once --prune-hours 24
# 北京一轮正常 ~2-3min,给 15min 上限防卡死
TimeoutStartSec=900
StandardOutput=journal
StandardError=journal
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Run Shaguabijia Meituan CPS coupon ETL (启用即跑一次, 之后每 1h)
[Timer]
# 启用/启动 timer 后立即触发一次(含开机自启、restart timer 时)
OnActiveSec=0
# 之后每隔 1 小时(相对上次 service 启动时刻)再触发;脚本自带文件锁,单轮 ~8min << 1h 不会重叠
OnUnitActiveSec=1h
[Install]
WantedBy=timers.target