Skip to content

Commit

Permalink
Merge pull request xiong233#1 from Alexandersande18/master
Browse files Browse the repository at this point in the history
加入dockerfile和scheduler方便本地部署
  • Loading branch information
xiong233 authored May 14, 2022
2 parents e208ec1 + df2d665 commit f7e9860
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/playwright/python:v1.22.0-focal

ENV APP_PATH="/"

ENV LC_ALL="C.UTF-8"

COPY ./main.py ./slide.py ./scheduler.py ./requirements.txt $APP_PATH/
ARG DEBIAN_FRONTEND=noninteractive

RUN pip install -r /requirements.txt

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

WORKDIR ${APP_PATH}

ENTRYPOINT [ "python3", "/scheduler.py"]
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
playwright
opencv-python
opencv-python
apscheduler
38 changes: 38 additions & 0 deletions scheduler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from apscheduler.schedulers.blocking import BlockingScheduler
import sys, os, subprocess

if os.environ.get('REPORT_ID') is None:
print("请配置环境变量REPORT_ID REPORT_PASSWORD", flush=True)
sys.exit(1)
id = os.environ.get('REPORT_ID')
passwd = os.environ.get("REPORT_PASSWORD")


def exec():
p = subprocess.Popen(['python', './main.py', id, passwd])
p.wait()
if p.returncode != 0:
print("[WARNING] exited with return code " + str(p.returncode))
return False
return True


# exec()
def job():
for i in range(3):
print("USER_ID=" + id + " Attempting for the " + str(i+1) + "th time" , flush=True)
print("**********************************stdout**********************************" , flush=True)
if exec():
print("Success" , flush=True)
print("**********************************stdout**********************************" , flush=True)
return
print("**********************************stdout**********************************" , flush=True)


scheduler_report = BlockingScheduler()
scheduler_report.add_job(job, 'cron', day='*', hour="8", minute="15", args=[], misfire_grace_time=300)
scheduler_report.add_job(job, 'cron', day='*', hour="8", minute="50", args=[], misfire_grace_time=300)
scheduler_report.add_job(job, 'cron', day='*', hour="9", minute="15", args=[], misfire_grace_time=300)
job()
print("job started", flush=True)
scheduler_report.start()

0 comments on commit f7e9860

Please sign in to comment.