diff --git a/dodo.py b/dodo.py index af562bf..f1057fb 100644 --- a/dodo.py +++ b/dodo.py @@ -104,6 +104,30 @@ def task_up(): } +def restart(*containers): + '''This actually restart the container(s).''' + srv = subprocess.check_output((COMPOSE + ' config --services').split()) + services = srv.decode('utf-8').strip().split() + for container in containers: + if container not in services: + raise ValueError("%s is not among the services %r" % (container, services)) + subprocess.check_call((COMPOSE + 'restart %s' % container).split()) + return True + + +def task_restart(*containers): + '''Restarts a container specified via commandline.''' + return { + 'params': [{'name': 'services', + 'short': 's', + 'long': 'service', + 'type': list, + 'default': [], + 'help': "the list of services to be restarted"}], + 'actions': [(restart, containers)], + } + + def task__cleanall(): '''clean everything there is to clean''' return {