|
@@ -8,56 +8,19 @@ import psutil
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../")
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../")
|
|
from format_convert.utils import get_ip_port, get_intranet_ip, get_args_from_config, get_all_ip, get_using_ip
|
|
from format_convert.utils import get_ip_port, get_intranet_ip, get_args_from_config, get_all_ip, get_using_ip
|
|
|
|
|
|
-# ip_port_dict = get_ip_port()
|
|
|
|
-# ip = "http://" + get_intranet_ip()
|
|
|
|
-# ip = "http://127.0.0.1"
|
|
|
|
-# convert_port_list = ip_port_dict.get(ip).get("convert")
|
|
|
|
-# ocr_port_list = ip_port_dict.get(ip).get("ocr")
|
|
|
|
-# otr_port_list = ip_port_dict.get(ip).get("otr")
|
|
|
|
-# soffice_port_list = ip_port_dict.get(ip).get("office")
|
|
|
|
-# if not convert_port_list:
|
|
|
|
-# convert_port_list = []
|
|
|
|
-# if not ocr_port_list:
|
|
|
|
-# ocr_port_list = []
|
|
|
|
-# if not otr_port_list:
|
|
|
|
-# otr_port_list = []
|
|
|
|
-# if not soffice_port_list:
|
|
|
|
-# soffice_port_list = []
|
|
|
|
-#
|
|
|
|
-# # schedule_port_list = ip_port_dict.get(ip).get("schedule")
|
|
|
|
-# # python_path = ip_port_dict.get(ip).get("python_path")
|
|
|
|
-# # project_path = ip_port_dict.get(ip).get("project_path")
|
|
|
|
-#
|
|
|
|
-# interface_path = project_path[:-1]
|
|
|
|
-# std_out = " >>/convert.out 2>&1 &"
|
|
|
|
-# std_out_gpu = " >>/gpu.out 2>&1 &"
|
|
|
|
-# std_out_schedule = " >>/schedule.out 2>&1 &"
|
|
|
|
-# # convert_comm = "nohup " + python_path + " " + interface_path + "/format_convert/convert.py #" + std_out
|
|
|
|
-# # ocr_comm = "nohup " + python_path + " " + interface_path + "/ocr/ocr_gpu_interface.py # 0" + std_out_gpu
|
|
|
|
-# # otr_comm = "nohup " + python_path + " " + interface_path + "/otr/otr_gpu_interface.py # 0" + std_out_gpu
|
|
|
|
-# schedule_comm = "nohup " + python_path + " " + interface_path + "/format_convert/schedule_interface.py #" + std_out_schedule
|
|
|
|
-# soffice_comm = "docker run --init -itd --log-opt max-size=10m --log-opt max-file=3 -p #:16000 soffice:v2 bash"
|
|
|
|
-#
|
|
|
|
-#
|
|
|
|
-# gunicorn_path = python_path
|
|
|
|
-# # print("convert_port_list", len(convert_port_list))
|
|
|
|
-# convert_comm = "nohup " + gunicorn_path + " -w " + str(len(convert_port_list)) + " -t 300 -b 0.0.0.0:# --chdir " \
|
|
|
|
-# + interface_path + "/format_convert convert:app" + std_out
|
|
|
|
-# ocr_comm = "nohup " + gunicorn_path + " -w " + str(len(ocr_port_list)) + " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir " \
|
|
|
|
-# + interface_path + "/ocr ocr_gpu_interface:app" + std_out_gpu
|
|
|
|
-# otr_comm = "nohup " + gunicorn_path + " -w " + str(len(otr_port_list)) + " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir " \
|
|
|
|
-# + interface_path + "/otr otr_gpu_interface:app" + std_out_gpu
|
|
|
|
-
|
|
|
|
|
|
|
|
ip_port_dict = get_ip_port()
|
|
ip_port_dict = get_ip_port()
|
|
ip = get_using_ip()
|
|
ip = get_using_ip()
|
|
print("local ip:", ip)
|
|
print("local ip:", ip)
|
|
|
|
|
|
|
|
+# 获取各个参数
|
|
convert_port_list = get_args_from_config(ip_port_dict, ip, "convert", "MASTER")
|
|
convert_port_list = get_args_from_config(ip_port_dict, ip, "convert", "MASTER")
|
|
if convert_port_list:
|
|
if convert_port_list:
|
|
convert_port_list = convert_port_list[0]
|
|
convert_port_list = convert_port_list[0]
|
|
ocr_port_list = get_args_from_config(ip_port_dict, ip, "ocr")
|
|
ocr_port_list = get_args_from_config(ip_port_dict, ip, "ocr")
|
|
otr_port_list = get_args_from_config(ip_port_dict, ip, "otr")
|
|
otr_port_list = get_args_from_config(ip_port_dict, ip, "otr")
|
|
|
|
+idc_port_list = get_args_from_config(ip_port_dict, ip, "idc")
|
|
|
|
+isr_port_list = get_args_from_config(ip_port_dict, ip, "isr")
|
|
soffice_port_list = get_args_from_config(ip_port_dict, ip, "office", "MASTER")
|
|
soffice_port_list = get_args_from_config(ip_port_dict, ip, "office", "MASTER")
|
|
if soffice_port_list:
|
|
if soffice_port_list:
|
|
soffice_port_list = soffice_port_list[0]
|
|
soffice_port_list = soffice_port_list[0]
|
|
@@ -71,11 +34,15 @@ std_out_schedule = " >>/schedule.out 2>&1 &"
|
|
print("convert_port_list", convert_port_list)
|
|
print("convert_port_list", convert_port_list)
|
|
print("ocr_port_list", ocr_port_list)
|
|
print("ocr_port_list", ocr_port_list)
|
|
print("otr_port_list", otr_port_list)
|
|
print("otr_port_list", otr_port_list)
|
|
|
|
+print("idc_port_list", idc_port_list)
|
|
|
|
+print("isr_port_list", isr_port_list)
|
|
print("soffice_port_list", soffice_port_list)
|
|
print("soffice_port_list", soffice_port_list)
|
|
|
|
|
|
-
|
|
|
|
|
|
+# 根据port生成gunicorn语句
|
|
ocr_comm_list = []
|
|
ocr_comm_list = []
|
|
otr_comm_list = []
|
|
otr_comm_list = []
|
|
|
|
+isr_comm_list = []
|
|
|
|
+idc_comm_list = []
|
|
for i in range(len(ocr_port_list)):
|
|
for i in range(len(ocr_port_list)):
|
|
ocr_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(ocr_port_list[i]))
|
|
ocr_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(ocr_port_list[i]))
|
|
+ " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
+ " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
@@ -84,9 +51,16 @@ for i in range(len(otr_port_list)):
|
|
otr_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(otr_port_list[i]))
|
|
otr_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(otr_port_list[i]))
|
|
+ " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
+ " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
+ project_path_list[i] + "/otr otr_interface:app" + std_out_gpu)
|
|
+ project_path_list[i] + "/otr otr_interface:app" + std_out_gpu)
|
|
|
|
+for i in range(len(idc_port_list)):
|
|
|
|
+ idc_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(idc_port_list[i]))
|
|
|
|
+ + " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
|
|
+ + project_path_list[i] + "/idc idc_interface:app" + std_out_gpu)
|
|
|
|
+for i in range(len(isr_port_list)):
|
|
|
|
+ isr_comm_list.append("nohup " + gunicorn_path_list[i] + " -w " + str(len(isr_port_list[i]))
|
|
|
|
+ + " -t 300 --keep-alive 600 -b 0.0.0.0:# --chdir "
|
|
|
|
+ + project_path_list[i] + "/isr isr_interface:app" + std_out_gpu)
|
|
convert_comm = "nohup " + gunicorn_path_list[0] + " -w " + str(len(convert_port_list)) + " -t 300 -b 0.0.0.0:# --chdir " \
|
|
convert_comm = "nohup " + gunicorn_path_list[0] + " -w " + str(len(convert_port_list)) + " -t 300 -b 0.0.0.0:# --chdir " \
|
|
+ project_path_list[0] + "/format_convert convert:app" + std_out
|
|
+ project_path_list[0] + "/format_convert convert:app" + std_out
|
|
-schedule_comm = "nohup " + python_path_list[0] + " " + project_path_list[0] + "/format_convert/schedule_interface.py #" + std_out_schedule
|
|
|
|
soffice_comm = "docker run --init -itd --log-opt max-size=10m --log-opt max-file=3 -p #:16000 soffice:v2 bash"
|
|
soffice_comm = "docker run --init -itd --log-opt max-size=10m --log-opt max-file=3 -p #:16000 soffice:v2 bash"
|
|
|
|
|
|
|
|
|
|
@@ -109,8 +83,10 @@ def restart(process_type, port, index=0):
|
|
_comm = re.sub("#", port, otr_comm_list[index])
|
|
_comm = re.sub("#", port, otr_comm_list[index])
|
|
elif process_type == "soffice":
|
|
elif process_type == "soffice":
|
|
_comm = re.sub("#", port, soffice_comm)
|
|
_comm = re.sub("#", port, soffice_comm)
|
|
- elif process_type == "schedule":
|
|
|
|
- _comm = re.sub("#", port, schedule_comm)
|
|
|
|
|
|
+ elif process_type == "idc":
|
|
|
|
+ _comm = re.sub("#", port, idc_comm_list[index])
|
|
|
|
+ elif process_type == "isr":
|
|
|
|
+ _comm = re.sub("#", port, isr_comm_list[index])
|
|
else:
|
|
else:
|
|
_comm = "netstat -nltp"
|
|
_comm = "netstat -nltp"
|
|
print("no process_type", process_type)
|
|
print("no process_type", process_type)
|
|
@@ -195,6 +171,18 @@ def monitor():
|
|
if p not in current_port_list:
|
|
if p not in current_port_list:
|
|
restart("otr", p, index=j)
|
|
restart("otr", p, index=j)
|
|
|
|
|
|
|
|
+ if idc_port_list:
|
|
|
|
+ for j in range(len(idc_port_list)):
|
|
|
|
+ for p in idc_port_list[j][:1]:
|
|
|
|
+ if p not in current_port_list:
|
|
|
|
+ restart("idc", p, index=j)
|
|
|
|
+
|
|
|
|
+ if isr_port_list:
|
|
|
|
+ for j in range(len(isr_port_list)):
|
|
|
|
+ for p in isr_port_list[j][:1]:
|
|
|
|
+ if p not in current_port_list:
|
|
|
|
+ restart("isr", p, index=j)
|
|
|
|
+
|
|
if soffice_port_list:
|
|
if soffice_port_list:
|
|
for p in soffice_port_list:
|
|
for p in soffice_port_list:
|
|
if p not in current_port_list:
|
|
if p not in current_port_list:
|