|
@@ -14,17 +14,17 @@ from concurrent.futures import ThreadPoolExecutor
|
|
health_instances = []
|
|
health_instances = []
|
|
|
|
|
|
|
|
|
|
-def longvideo_health_check(client, instance_id, max_wait_time=None):
|
|
|
|
|
|
+def longvideo_health_check(ecs_client, instance_id, max_wait_time=None):
|
|
"""
|
|
"""
|
|
服务健康检查
|
|
服务健康检查
|
|
- :param client: 客户端连接
|
|
|
|
|
|
+ :param ecs_client: 客户端连接
|
|
:param instance_id: instanceId
|
|
:param instance_id: instanceId
|
|
:param max_wait_time: 最长等待时间,单位:s
|
|
:param max_wait_time: 最长等待时间,单位:s
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
global health_instances
|
|
global health_instances
|
|
start_time = time.time()
|
|
start_time = time.time()
|
|
- ip_address = utils.get_ip_address(client=client, instance_id=instance_id)
|
|
|
|
|
|
+ ip_address = utils.get_ip_address(ecs_client=ecs_client, instance_id=instance_id)
|
|
while True:
|
|
while True:
|
|
health_check_url = f"http://{ip_address}:8080/longvideoapi/test"
|
|
health_check_url = f"http://{ip_address}:8080/longvideoapi/test"
|
|
try:
|
|
try:
|
|
@@ -60,19 +60,19 @@ async def ess_instance(ecs_client, alb_client, ess_count, max_workers):
|
|
# 1. 购买机器并启动
|
|
# 1. 购买机器并启动
|
|
ess_instance_ids = utils.create_multiple_instances(
|
|
ess_instance_ids = utils.create_multiple_instances(
|
|
amount=ess_count,
|
|
amount=ess_count,
|
|
- client=ecs_client,
|
|
|
|
|
|
+ ecs_client=ecs_client,
|
|
**longvideoapi_config.instance_config_k,
|
|
**longvideoapi_config.instance_config_k,
|
|
)
|
|
)
|
|
time.sleep(60)
|
|
time.sleep(60)
|
|
|
|
|
|
# 2. 发送启动脚本到机器上
|
|
# 2. 发送启动脚本到机器上
|
|
- utils.send_file_to_ecs(client=ecs_client, instance_id_list=ess_instance_ids, **longvideoapi_config.start_sh)
|
|
|
|
|
|
+ utils.send_file_to_ecs(ecs_client=ecs_client, instance_id_list=ess_instance_ids, **longvideoapi_config.start_sh)
|
|
logging.info(f"send start shell file finished, instances: {ess_instance_ids}")
|
|
logging.info(f"send start shell file finished, instances: {ess_instance_ids}")
|
|
# 3. 启动服务
|
|
# 3. 启动服务
|
|
start_sh_param = "latest"
|
|
start_sh_param = "latest"
|
|
server_start_sh = os.path.join(longvideoapi_config.start_sh['target_dir'], longvideoapi_config.start_sh['name'])
|
|
server_start_sh = os.path.join(longvideoapi_config.start_sh['target_dir'], longvideoapi_config.start_sh['name'])
|
|
server_start_commend = f"sh {server_start_sh} {start_sh_param}"
|
|
server_start_commend = f"sh {server_start_sh} {start_sh_param}"
|
|
- utils.run_command(client=ecs_client, instance_ids=ess_instance_ids, command=server_start_commend)
|
|
|
|
|
|
+ utils.run_command(ecs_client=ecs_client, instance_ids=ess_instance_ids, command=server_start_commend)
|
|
# 4. 异步探活
|
|
# 4. 异步探活
|
|
global health_instances
|
|
global health_instances
|
|
health_instances = []
|
|
health_instances = []
|