bugfix: 修改定时任务错误
This commit is contained in:
parent
bd5580ee4b
commit
16c7b2405d
|
|
@ -27,4 +27,4 @@ COPY . /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "-u", "main.py"]
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,7 @@ services:
|
||||||
image: "schedule_tasks"
|
image: "schedule_tasks"
|
||||||
container_name: "schedule_tasks"
|
container_name: "schedule_tasks"
|
||||||
restart: always
|
restart: always
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:172.17.0.1"
|
||||||
# ports:
|
# ports:
|
||||||
# - "18000:8000"
|
# - "18000:8000"
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class Lottery(object):
|
||||||
raise Exception("未知的lottery_type")
|
raise Exception("未知的lottery_type")
|
||||||
|
|
||||||
def _get_db_session(self):
|
def _get_db_session(self):
|
||||||
_engine = create_engine("mysql+pymysql://root:Chenweijia113!@172.17.0.1/lottery?charset=utf8", pool_pre_ping=True, pool_recycle=3600)
|
_engine = create_engine("mysql+pymysql://root:Chenweijia113!@host.docker.internal/lottery?charset=utf8", pool_pre_ping=True, pool_recycle=3600)
|
||||||
_DbSession = sessionmaker(bind=_engine)
|
_DbSession = sessionmaker(bind=_engine)
|
||||||
return _DbSession()
|
return _DbSession()
|
||||||
|
|
||||||
|
|
|
||||||
7
main.py
7
main.py
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime
|
||||||
from retrying import retry
|
from retrying import retry
|
||||||
from schedule import every, repeat, run_pending
|
from schedule import every, repeat, run_pending
|
||||||
from requests_html import HTML, HTMLSession
|
from requests_html import HTML, HTMLSession
|
||||||
|
|
@ -41,14 +42,20 @@ def get_data_job(lottery_type='pls', issue=None):
|
||||||
|
|
||||||
@repeat(every().day.at("00:01"))
|
@repeat(every().day.at("00:01"))
|
||||||
def pls_job():
|
def pls_job():
|
||||||
|
time_now = datetime.now()
|
||||||
|
print(f"当前任务运行时间为: {time_now.strftime('%H:%M:%S')}")
|
||||||
get_data_job(lottery_type='pls')
|
get_data_job(lottery_type='pls')
|
||||||
|
|
||||||
@repeat(every().day.at("00:02"))
|
@repeat(every().day.at("00:02"))
|
||||||
def plw_job():
|
def plw_job():
|
||||||
|
time_now = datetime.now()
|
||||||
|
print(f"当前任务运行时间为: {time_now.strftime('%H:%M:%S')}")
|
||||||
get_data_job(lottery_type='plw')
|
get_data_job(lottery_type='plw')
|
||||||
|
|
||||||
@repeat(every().day.at("00:03"))
|
@repeat(every().day.at("00:03"))
|
||||||
def sd_job():
|
def sd_job():
|
||||||
|
time_now = datetime.now()
|
||||||
|
print(f"当前任务运行时间为: {time_now.strftime('%H:%M:%S')}")
|
||||||
get_data_job(lottery_type='sd')
|
get_data_job(lottery_type='sd')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,5 @@ retry==0.9.2
|
||||||
retrying==1.3.4
|
retrying==1.3.4
|
||||||
schedule==1.2.0
|
schedule==1.2.0
|
||||||
SQLAlchemy==2.0.11
|
SQLAlchemy==2.0.11
|
||||||
|
lxml==4.9.2
|
||||||
|
cryptography==42.0.5
|
||||||
Loading…
Reference in New Issue