Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
zhongmengqi | 6dad366b3c | |
Koutakui | accf227701 | |
zhongmengqi | 5abd0723f8 | |
Luumos | 017869b71f |
20
main.py
20
main.py
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue