Compare commits
3 commits
c64ce844d1
...
40b853d71a
Author | SHA1 | Date | |
---|---|---|---|
40b853d71a | |||
9c5a8f4379 | |||
cf3163979a |
1 changed files with 21 additions and 10 deletions
31
dodo.py
31
dodo.py
|
@ -1,5 +1,6 @@
|
|||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
|
||||
from doit.tools import LongRunning
|
||||
|
||||
|
@ -8,7 +9,7 @@ from dodo_utils import wait_net_service, wait_pgsql_db, \
|
|||
run_task_func, scan_dir
|
||||
|
||||
COMPOSE = 'docker-compose -p feedati'
|
||||
DOIT_CONFIG = {'default_tasks': ['up']}
|
||||
DOIT_CONFIG = {'default_tasks': ['up'], 'backend': 'sqlite3'}
|
||||
|
||||
|
||||
def task_build():
|
||||
|
@ -104,18 +105,28 @@ def task_up():
|
|||
}
|
||||
|
||||
|
||||
def restart(*containers):
|
||||
'''This actually restart the container(s).'''
|
||||
def _get_valid_services():
|
||||
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 srv.decode('utf-8').strip().split()
|
||||
|
||||
|
||||
def restart(services):
|
||||
'''This actually restart the container(s).'''
|
||||
valid = _get_valid_services()
|
||||
err = False
|
||||
for service in services:
|
||||
if service not in valid:
|
||||
print('ERROR: invalid service %s' % service, file=sys.stderr)
|
||||
err = True
|
||||
if err or not services:
|
||||
print('Valid services are: ' + ', '.join(valid), file=sys.stderr)
|
||||
return False
|
||||
for service in services:
|
||||
subprocess.check_call((COMPOSE + ' restart %s' % service).split())
|
||||
return True
|
||||
|
||||
|
||||
def task_restart(*containers):
|
||||
def task_restart():
|
||||
'''Restarts a container specified via commandline.'''
|
||||
return {
|
||||
'params': [{'name': 'services',
|
||||
|
@ -124,7 +135,7 @@ def task_restart(*containers):
|
|||
'type': list,
|
||||
'default': [],
|
||||
'help': "the list of services to be restarted"}],
|
||||
'actions': [(restart, containers)],
|
||||
'actions': [(restart, )],
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue