建模程序 多个定时程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
2.5 KiB

import sys,socket,time,platform
from logic import logic_main_service
import logging
import main_step1,main_step2,main_step3
if platform.system() == 'Windows':
#线上正式运行
sys.path.append('e:\\libs\\')
#本地测试
else:
sys.path.append('/data/deploy/make3d/make2/libs/')
import main_service_db
if __name__ == '__main__':
#循环值守
while True:
data = logic_main_service.get_task_distributed()
#判断data数据类型
if isinstance(data, str):
print("没有可执行的任务 sleep 3s")
time.sleep(3)
continue
else:
if data["run_step"] == "step1":
# 本地测试分布运行的用
time.sleep(5)
print("更新step1的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
main_service_db.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step1","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
#main_step1.step1(data["task_key"], experience=False, makeloop=False,task_distributed_id=data['task_distributed_id'])
elif data["run_step"] == "step2":
# 本地测试分布运行的用
time.sleep(15)
print("更新step2的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
main_service_db.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step2","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
#main_step2.step2(data["task_key"], data['task_distributed_id'])
elif data["run_step"] == "step3":
# 本地测试分布运行的用
time.sleep(8)
# #更新子表的finished_at
print("更新step3的结束时间",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
main_service_db.update_task_distributed_detail({"task_distributed_id":data["task_distributed_id"],"step":"step3","finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#更新主表的status 和 finished_at
main_service_db.update_task_distributed({"id":data["task_distributed_id"],"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
#生产线上用
#main_step3.step3(data["task_key"], data['task_distributed_id'])