Bläddra i källkod

更新定时任务和dockekrfile

hexiaoshi 1 år sedan
förälder
incheckning
184f4df1a5
3 ändrade filer med 11 tillägg och 7 borttagningar
  1. 7 4
      Dockerfile
  2. 3 2
      crontab
  3. 1 1
      烟草模型部署文档.md

+ 7 - 4
Dockerfile

@@ -1,6 +1,8 @@
 FROM registry.cn-hangzhou.aliyuncs.com/hexiaoshi/python:3.10
 
-RUN apt-get update && apt-get -y install cron vim
+RUN apt-get update && apt-get -y install  tzdata cron vim && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 
 WORKDIR /app
 
@@ -12,9 +14,10 @@ RUN mv /app/crontab /etc/cron.d/crontab && chmod 0644 /etc/cron.d/crontab \
         && pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple  \ 
         && pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
 
-RUN find . | grep -E "(__pycache__|Dockerfile|\.pyc|\.pyo$)" | xargs rm -rf && python3 -m compileall -b . \ 
-        &&  find . -name "*.py" |xargs rm -rf
+RUN find . | grep -E "(__pycache__|Dockerfile|\.md|\.pyc|\.pyo$)" | xargs rm -rf && python3 -m compileall -b . \ 
+        &&  find . -name "*.py" |xargs rm -rf && touch /var/log/cron.log
 
+VOLUME ["/etc/cron.d"]
 
-CMD ["cron", "-f"]
+CMD /bin/bash -c "/usr/bin/crontab /etc/cron.d/crontab && cron && tail -f /var/log/cron.log"
 

+ 3 - 2
crontab

@@ -1,3 +1,4 @@
 # START CRON JOB
-1 2 * * * python /app/app.pyc
-# END CRON JOB
+11 13 * * * cd /app && /usr/local/bin/python app.pyc --run_all >> /var/log/app.log 2>&1
+#* * * * * echo "asdf" >> /var/log/test.log
+# END CRON JOB

+ 1 - 1
烟草模型部署文档.md

@@ -25,7 +25,7 @@ redis:
 
 ```
 # START CRON JOB
-1 2 * * * python /app/app.pyc
+1 2 * * * python /app/app.pyc --run_all
 # END CRON JOB
 ```