|
@@ -16,6 +16,7 @@ import utils
|
|
# 从配置文件中获取应用程序名称和容器仓库地址
|
|
# 从配置文件中获取应用程序名称和容器仓库地址
|
|
apps = gateway_config.apps
|
|
apps = gateway_config.apps
|
|
repository = gateway_config.repository
|
|
repository = gateway_config.repository
|
|
|
|
+registry = gateway_config.registry
|
|
version = sys.argv[1] # 从命令行参数获取版本号
|
|
version = sys.argv[1] # 从命令行参数获取版本号
|
|
|
|
|
|
|
|
|
|
@@ -64,7 +65,7 @@ def update(instance_id):
|
|
docker_config = gateway_config.docker_config
|
|
docker_config = gateway_config.docker_config
|
|
client.login(username=docker_config['username'], password=docker_config['password'],
|
|
client.login(username=docker_config['username'], password=docker_config['password'],
|
|
registry=docker_config['registry'])
|
|
registry=docker_config['registry'])
|
|
- client.containers.run(repository, detach=True, cap_add='SYS_PTRACE', network_mode='host', name=apps,
|
|
|
|
|
|
+ client.containers.run(registry.format(apps, version), detach=True, cap_add='SYS_PTRACE', network_mode='host', name=apps,
|
|
volumes={'/datalog/': {'bind': '/datalog/', 'mode': 'rw'}})
|
|
volumes={'/datalog/': {'bind': '/datalog/', 'mode': 'rw'}})
|
|
print("开始健康检查")
|
|
print("开始健康检查")
|
|
checkHealth(ipadd)
|
|
checkHealth(ipadd)
|
|
@@ -89,7 +90,7 @@ def pull_image():
|
|
client = docker.DockerClient(base_url=cd_url, timeout=30)
|
|
client = docker.DockerClient(base_url=cd_url, timeout=30)
|
|
|
|
|
|
try:
|
|
try:
|
|
- client.images.pull(repository, tag=version)
|
|
|
|
|
|
+ client.images.pull(repository.format(apps), tag=version) #
|
|
print(ipaddr, "pull images success ")
|
|
print(ipaddr, "pull images success ")
|
|
return True
|
|
return True
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -105,7 +106,9 @@ if __name__ == '__main__':
|
|
|
|
|
|
# 初始化 ALB 客户端
|
|
# 初始化 ALB 客户端
|
|
alb_client = utils.connect_alb_client(gateway_config.alb_client_params['access_key_id'],
|
|
alb_client = utils.connect_alb_client(gateway_config.alb_client_params['access_key_id'],
|
|
- gateway_config.alb_client_params['access_key_secret'])
|
|
|
|
|
|
+ gateway_config.alb_client_params['access_key_secret'],
|
|
|
|
+ endpoint=gateway_config.alb_client_params['endpoint']
|
|
|
|
+ )
|
|
|
|
|
|
success_count = 0
|
|
success_count = 0
|
|
threads = []
|
|
threads = []
|