Commit 59d3e20e authored by José Henrique's avatar José Henrique
Browse files

Improve container start process

parent da07b5cb
......@@ -25,6 +25,19 @@ def kill_container(container_name):
pass
def is_container_running(container_name):
for container in docker_client.containers.list():
if container.name == container_name:
return True
return False
def wait_and_kill_container(container_name):
if is_container_running(container_name):
time.sleep(15)
kill_container(container_name)
def kill_process(pid):
try:
os.kill(pid, signal.SIGKILL)
......@@ -146,6 +159,7 @@ def start_notifier(environment_vars):
pull_image(image_name)
print("Starting notifier container...")
container_name = "notifier_" + environment_vars["build_id"]
wait_and_kill_container(container_name)
docker_client.containers.run(image_name,
detach=True,
remove=True,
......@@ -176,6 +190,7 @@ def sync_private_repos(environment_vars):
def start_build(environment_vars):
sync_private_repos(environment_vars)
container_name = environment_vars["build_id"]
wait_and_kill_container(container_name)
image_name = "pixelexperience/android_build_ci"
volumes_to_mount = {
environment_vars["working_dir"]: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment