Skip to content

Commit

Permalink
feat: 实现定时任务半小时内随机执行 #206 (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuweitung authored Nov 14, 2024
1 parent 971b867 commit 9aa06e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:alpine

RUN apk add --no-cache gcc g++ musl-dev python3-dev libffi-dev rust openssl-dev cargo pkgconfig
RUN apk add --no-cache gcc g++ musl-dev python3-dev libffi-dev rust openssl-dev cargo pkgconfig

RUN pip install --no-cache-dir pdm

Expand All @@ -11,7 +11,7 @@ COPY ./utils ./utils
COPY ./pyproject.toml ./pdm.lock ./miuitask.py ./docker_start.sh ./

RUN pdm install --prod && \
echo "0 4 * * * cd /srv && pdm run /srv/miuitask.py" > /var/spool/cron/crontabs/root && \
echo '0 4 * * * /bin/sh -c "sleep $((RANDOM % 1800 + 1)); cd /srv && pdm run /srv/miuitask.py"' > /var/spool/cron/crontabs/root && \
chmod +x docker_start.sh

VOLUME ["/srv/data", "/srv/logs"]
Expand Down

0 comments on commit 9aa06e0

Please sign in to comment.