Compare commits

...

4 Commits

Author SHA1 Message Date
zhongmengqi 6dad366b3c hzy
注释
2023-12-21 15:22:54 +08:00
Koutakui accf227701 Update main.py 2023-12-21 15:20:39 +08:00
zhongmengqi 5abd0723f8 Merge pull request '添加注释' (#1) from test into master 2023-12-17 19:18:14 +08:00
Luumos 017869b71f Update main.py 2023-12-14 14:01:46 +08:00
1 changed files with 14 additions and 6 deletions

20
main.py
View File

@ -1,29 +1,37 @@
#!/usr/bin/python
# 项目主函数入口
import datetime
import time
from commons.logUtil import logger
from controllers.prController import app
import datetime # datatime对time模块进行了更高级的封装提供了更高级的接口。
import time #time模块操作简单速度快适用于处理简单的时间计算和格式化
from commons.logUtil import logger #日志类工具
from controllers.prController import app #app是flask模块的实例用于接收web服务器的请求
from services.pullService import check_and_update_pull
from threading import Thread
from threading import Thread #threading是python中专门提供用来做多线程的模块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'))
# 暂停600s后继续执行
time.sleep(600)
# 定义程序运行函数
def run():
# 创建监控线程并启动
monitoring_thread = Thread(target=monitoring_loop)
monitoring_thread.start()
app.run(host=baseConfig.host, port=baseConfig.port)
# 运行应用程序
app.run(host=baseConfig.host, port=baseConfig.port) #host主机名port端口号
# 主程序入口
if __name__ == '__main__':
run()