PRWelBot4SECourse/main.py

41 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/python
# 项目主函数入口
# 导入必要的模块
import datetime
import time
from commons.logUtil import logger
from controllers.prController import app
from services.pullService import check_and_update_pull
from threading import Thread
import config.baseConfig as baseConfig
# 定义监控循环函数
def monitoring_loop():
while True:
# 调用检查和更新拉取的函数
check_and_update_pull()
# 获取当前时间
now = datetime.datetime.now()
# 记录信息到日志,表示执行定时任务
logger.info('执行定时任务 :' + now.strftime('%Y-%m-%d %H:%M:%S'))
# 休眠10分钟600秒
time.sleep(600)
# 定义运行函数
def run():
# 创建并启动监控线程
monitoring_thread = Thread(target=monitoring_loop)
monitoring_thread.start()
# 启动应用,指定主机和端口
app.run(host=baseConfig.host, port=baseConfig.port)
# 主程序入口
if __name__ == '__main__':
# 调用运行函数
run()