|
@@ -15,15 +15,15 @@ ess_instances = []
|
|
remove_container_instances = []
|
|
remove_container_instances = []
|
|
|
|
|
|
|
|
|
|
-def server_health_check(client, instance_id):
|
|
|
|
|
|
+def server_health_check(ecs_client, instance_id):
|
|
"""
|
|
"""
|
|
服务健康检查
|
|
服务健康检查
|
|
- :param client: 客户端连接
|
|
|
|
|
|
+ :param ecs_client: 客户端连接
|
|
:param instance_id: instanceId
|
|
:param instance_id: instanceId
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
global health_instances
|
|
global health_instances
|
|
- 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:
|
|
@@ -40,15 +40,15 @@ def server_health_check(client, instance_id):
|
|
time.sleep(10)
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
|
|
-def remove_container_image(client, instance_id, container_name_list):
|
|
|
|
|
|
+def remove_container_image(ecs_client, instance_id, container_name_list):
|
|
"""
|
|
"""
|
|
移除旧容器并删除旧镜像
|
|
移除旧容器并删除旧镜像
|
|
- :param client: 客户端连接
|
|
|
|
|
|
+ :param ecs_client: 客户端连接
|
|
:param instance_id: instanceId type-string
|
|
:param instance_id: instanceId type-string
|
|
:param container_name_list: 容器名称 type-list
|
|
:param container_name_list: 容器名称 type-list
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- 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)
|
|
logging.info(f"服务器信息:{instance_id}/{ip_address}")
|
|
logging.info(f"服务器信息:{instance_id}/{ip_address}")
|
|
client = docker.DockerClient(base_url=f'tcp://{ip_address}:2375', timeout=60)
|
|
client = docker.DockerClient(base_url=f'tcp://{ip_address}:2375', timeout=60)
|
|
|
|
|
|
@@ -104,7 +104,7 @@ def update_instance(ecs_client, alb_client, instance_id, version):
|
|
logging.info(f"update instance: {instance_id}")
|
|
logging.info(f"update instance: {instance_id}")
|
|
# 1. 摘流量,将权重降为0
|
|
# 1. 摘流量,将权重降为0
|
|
health_instance_ids = [instance_id]
|
|
health_instance_ids = [instance_id]
|
|
- weight_list = [(0, 15)] # 设置权重为0,等待15秒
|
|
|
|
|
|
+ weight_list = [(0, 20)] # 设置权重为0,等待20秒
|
|
utils.set_instance_weight_process_with_alb(alb_client,
|
|
utils.set_instance_weight_process_with_alb(alb_client,
|
|
longvideoapi_config.server_group_id_list,
|
|
longvideoapi_config.server_group_id_list,
|
|
health_instance_ids,
|
|
health_instance_ids,
|
|
@@ -145,7 +145,6 @@ def update_instance(ecs_client, alb_client, instance_id, version):
|
|
time.sleep(10)
|
|
time.sleep(10)
|
|
# 使用 ALB 的函数挂载实例
|
|
# 使用 ALB 的函数挂载实例
|
|
# health_instance_ids = [instance_id for instance_id, _ in health_instances]
|
|
# health_instance_ids = [instance_id for instance_id, _ in health_instances]
|
|
- # todo
|
|
|
|
# for server_group_id in longvideoapi_config.server_group_id_list:
|
|
# for server_group_id in longvideoapi_config.server_group_id_list:
|
|
# for instance_id in health_instance_ids:
|
|
# for instance_id in health_instance_ids:
|
|
# utils.add_servers_to_server_group(alb_client, server_group_id, instance_id, weight=0)
|
|
# utils.add_servers_to_server_group(alb_client, server_group_id, instance_id, weight=0)
|
|
@@ -164,8 +163,6 @@ def main():
|
|
version = sys.argv[1]
|
|
version = sys.argv[1]
|
|
alb_client = utils.connect_alb_client(access_key_id=longvideoapi_config.alb_client_params['access_key_id'],
|
|
alb_client = utils.connect_alb_client(access_key_id=longvideoapi_config.alb_client_params['access_key_id'],
|
|
access_key_secret=longvideoapi_config.alb_client_params['access_key_secret'])
|
|
access_key_secret=longvideoapi_config.alb_client_params['access_key_secret'])
|
|
- # todo
|
|
|
|
-
|
|
|
|
ecs_client = utils.connect_client(access_key_id=longvideoapi_config.ecs_client_params['access_key_id'],
|
|
ecs_client = utils.connect_client(access_key_id=longvideoapi_config.ecs_client_params['access_key_id'],
|
|
access_key_secret=longvideoapi_config.ecs_client_params[
|
|
access_key_secret=longvideoapi_config.ecs_client_params[
|
|
'access_key_secret'],
|
|
'access_key_secret'],
|