forked from xiong233/uestc_report_playwright
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request xiong233#1 from Alexandersande18/master
加入dockerfile和scheduler方便本地部署
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
playwright | ||
opencv-python | ||
opencv-python | ||
apscheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |