Files
shaguabijia-app-server/deploy/daily-exchange.service
no_gen_mu 4d821bec26 feat(invite): 发奖口径改为「比价并下单」+ 好友已比价状态(is_compared) + DEV 造数/重置接口
- 邀请发奖触发从「上报比价」改为「实际下单」(order.py + compare_record.py + repositories/invite.py)
- 好友列表返回 is_compared 已比价状态 (schemas/invite.py + repositories/invite.py)
- 新增 DEV 内部接口(生产 is_prod 一律 404):
  - POST/DELETE /invite/seed-fake 造/清虚拟好友(测在途、好友列表 UI)
  - POST /invite/dev-reset 把固定测试号打回出厂态(反复当新用户测发奖)
- fix(deploy): 每日兑换定时器锁北京时区 Asia/Shanghai (daily-exchange.service/.timer)

不含测试文件(tests/ 及 scripts/invite_reward_e2e.* 本地自用,不入库)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 17:13:50 +08:00

37 lines
1.7 KiB
Desktop File

# 0 点自动兑金币 —— 单轮把每个用户金币「到分全额」兑成现金,由 daily-exchange.timer 每天 0 点触发。
#
# 仅用于 Linux 服务器;本机 Windows 开发无 systemd,直接手动跑脚本即可:
# .venv\Scripts\python -m scripts.daily_auto_exchange --once
#
# 部署(服务器):
# sudo cp deploy/daily-exchange.{service,timer} /etc/systemd/system/
# sudo systemctl daemon-reload && sudo systemctl enable --now daily-exchange.timer
# # 手动跑一次验证: sudo systemctl start daily-exchange.service && journalctl -u daily-exchange -n 30
#
# 前置:.env 的 AUTO_EXCHANGE_ENABLED=true(默认);置 false 则脚本 no-op,免动 timer。
[Unit]
Description=Daily auto-exchange coins to cash (one-shot, driven by timer)
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=root
WorkingDirectory=/opt/shaguabijia-app-server
Environment="PATH=/opt/shaguabijia-app-server/.venv/bin:/usr/bin:/bin"
# 写死北京时:兑换的"当天/0 点"一律按北京时,不随服务器 OS 时区漂(用户 2026-07-01 硬约束)。
# 脚本内的日期判断本就走 rewards.cn_today()(CN_TZ=+8),这里再把进程 TZ 也钉成北京,双保险。
Environment="TZ=Asia/Shanghai"
EnvironmentFile=/opt/shaguabijia-app-server/.env
ExecStart=/opt/shaguabijia-app-server/.venv/bin/python -m scripts.daily_auto_exchange --once
SyslogIdentifier=daily-exchange
# 脚本自带 30min 文件锁;给 20min 硬超时,防卡死轮次长期占锁。
TimeoutStartSec=1200
# 与主服务 shaguabijia-app-server.service 同款加固。
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ReadWritePaths=/opt/shaguabijia-app-server
ProtectHome=true