1234567891011121314151617181920212223242526 |
- import os
- import time
- def server_run(port, command):
- # 设置服务缓存时间(防止更新服务产生冲突)
- time.sleep(12)
- 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:
- retrieval_app_server = os.popen("lsof -i:8835").readlines()
- if not retrieval_app_server:
- # server_run(8835, "nohup python retrieval_app.py >> logs/retrieval_app.log 2>&1 &")
- server_run(8835, "gunicorn -c guc_conf.py retrieval_app:app")
- hnsw_app_server = os.popen("lsof -i:8836").readlines()
- if not hnsw_app_server:
- server_run(8836, "nohup python hnsw_app.py > logs/temp_app.log 2>&1 &")
- dim_classify_app_server = os.popen("lsof -i:8837").readlines()
- if not dim_classify_app_server:
- server_run(8837, "nohup python dim_classify_app.py > logs/temp_app.log 2>&1 &")
|