Skip to content

Commit

Permalink
wait until watchtower exits to move on
Browse files Browse the repository at this point in the history
  • Loading branch information
SelfhostedPro committed Sep 30, 2020
1 parent 87b7aeb commit 6761a5b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions backend/api/actions/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..utils import *

from datetime import datetime
import time
import subprocess
import docker

Expand Down Expand Up @@ -153,14 +154,17 @@ def app_update(app_name):
dclient = docker.from_env()
old = dclient.containers.get(app_name)
volumes ={'/var/run/docker.sock': {'bind':'/var/run/docker.sock', 'mode': 'rw'}}
dclient.containers.run(
updater = dclient.containers.run(
image='containrrr/watchtower:latest',
command='--run-once '+old.name,
detach=False,
stream=True,
remove=True,
detach=True,
volumes=volumes
)
print('**** Updating '+old.name+'****')
result = updater.wait(timeout=120)
print(result)
time.sleep(1)
return get_apps()

def update_self():
Expand All @@ -169,14 +173,17 @@ def update_self():
yacht_id = subprocess.check_output(['bash','-c', bash_command]).decode('UTF-8').strip()
yacht = dclient.containers.get(yacht_id)
volumes ={'/var/run/docker.sock': {'bind':'/var/run/docker.sock', 'mode': 'rw'}}
dclient.containers.run(
print('**** Updating '+yacht.name+'****')
updater = dclient.containers.run(
image='containrrr/watchtower:latest',
command='--run-once '+yacht.name,
detach=False,
stream=True,
remove=True,
detach=True,
volumes=volumes
)
result = updater.wait(timeout=120)
print(result)
time.sleep(1)
return get_apps()

def prune_images():
Expand Down

0 comments on commit 6761a5b

Please sign in to comment.