forked from Trustie-Study-Group/PRWelBot4SECourse
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
#!/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()
|