1234567891011121314151617181920212223242526272829 |
- import os
- import time
- import datetime
- def server_run(port, command):
- # 设置服务缓存时间(防止更新服务产生冲突)
- time.sleep(12) if port == 8858 else time.sleep(8)
- server = os.popen("lsof -i:{}".format(port)).readlines()
- if not server:
- print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
- "即将启动{}端口服务".format(port))
- # 启动服务
- os.popen(command)
- while True:
- math_dup_app_server = os.popen("lsof -i:8855").readlines()
- if not math_dup_app_server:
- # server_run(8855, "nohup python math_dup_app.py >> logs/math_dup_app.log 2>&1 &")
- server_run(8855, "gunicorn -c guc_conf.py math_dup_app:app")
-
- rlt_ddc_app_server = os.popen("lsof -i:8856").readlines()
- if not rlt_ddc_app_server:
- server_run(8856, "nohup python rlt_ddc_app.py >> logs/rlt_ddc_app.log 2>&1 &")
- hnsw_app_server = os.popen("lsof -i:8858").readlines()
- if not hnsw_app_server:
- current_time = datetime.datetime.now()
- if current_time.weekday() not in {0,3} or current_time.hour > 5:
- server_run(8858, "nohup python hnsw_app.py > logs/temp_app.log 2>&1 &")
|