feat(upstream): 上游更新检查——定期比上游、落后了推企业微信
本仓库在上游 MediaCrawler 之上加了一整层(见 UPSTREAM.md),可合并流程默认 「有人知道上游动了」。而部署是 git pull --ff-only,只从自己的 Gitea 拉——上游的 提交不主动 fetch 就永远看不见。拖着不合并的代价是复利的:越久越难合。 于是把「上游动了没有」变成一条会自己跑、会推企业微信的通知: * api/monitor/upstream.py:git fetch <url> <branch> 到 FETCH_HEAD,用 rev-list --count HEAD..FETCH_HEAD 算落后数、FETCH_HEAD..HEAD 算领先数。 用 git 而非托管商 API,因为只有 git 知道共同祖先在哪——本仓库含有上游没有的 提交,直接比 tip 会得出错误结论。增量 fetch 只传几个新提交,不会遇到 UPSTREAM.md 里说的「大包必断」。 * 只 fetch 到 FETCH_HEAD:不配 remote、不写 refs/remotes、不碰索引与工作区, 所以不打断正在跑的采集,也不和 deploy.sh 的 git pull 抢锁。 * 挂在调度器 tick 上(不是采集,所以不看 is_busy、不受活跃时段限制——定时检查 放在半夜反而最合适),按 checked_at + 间隔 到期才跑;失败也写 checked_at, 于是 GitHub 不通时是每间隔重试一次,而不是每个 tick 撞一次墙。 * 同一个 tip 只推一次(记 tip 而不是「推过没」),上游真又动了会再推。 * 两个接口:GET /monitor/upstream 只读缓存;POST /monitor/upstream/check 手动 查一次且刻意不推通知——点按钮的人正看着结果。 * 默认关闭,间隔默认一天。 Dockerfile 显式装 git(python:slim 不带,而这是唯一的依赖);deploy.sh 顺带补上 一个真 bug 的提示:Dockerfile/requirements.txt 变了只 up -d 用的还是旧镜像。
This commit is contained in:
+5
-1
@@ -35,6 +35,10 @@ ENV PYTHONUNBUFFERED=1 \
|
||||
#
|
||||
# The pip mirror is set for the same reason as the apt one: this host's route to
|
||||
# the public index is slow.
|
||||
#
|
||||
# git is for the 上游更新检查 (api/monitor/upstream.py): it fetches the upstream
|
||||
# repository into the mounted checkout to count how far behind this fork is.
|
||||
# python:slim does not ship git, and nothing else here pulls it in.
|
||||
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||
RUN set -eux; \
|
||||
for f in /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources; do \
|
||||
@@ -44,7 +48,7 @@ RUN set -eux; \
|
||||
done; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential pkg-config default-libmysqlclient-dev \
|
||||
build-essential pkg-config default-libmysqlclient-dev git \
|
||||
libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libxcb1 libgomp1 \
|
||||
tzdata nodejs npm; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
Reference in New Issue
Block a user