e2cc_app_monitor.py 728 B

123456789101112131415161718192021222324
  1. import os
  2. import time
  3. def server_run(port, command):
  4. # 设置服务缓存时间(防止更新服务产生冲突)
  5. # server = os.popen("lsof -i:{}".format(port)).readlines()
  6. # if not server:
  7. print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
  8. "即将启动{}端口服务".format(port))
  9. # 启动服务
  10. os.popen(command)
  11. while True:
  12. time.sleep(5)
  13. e2cc_app_server = os.popen("lsof -i:10116").readlines()
  14. if not e2cc_app_server:
  15. # server_run(10116, "gunicorn -D -c gconfig.py E2CC_server:app product")
  16. server_run(10116, "nohup python E2CC_server.py product > logs/temp.log 2>&1")
  17. # server_run(10116, "gunicorn -D -c gconfig.py E2CC_server:app test")