Compare commits
4 commits
0e42a12610
...
40b853d71a
Author | SHA1 | Date | |
---|---|---|---|
40b853d71a | |||
9c5a8f4379 | |||
cf3163979a | |||
c64ce844d1 |
1 changed files with 36 additions and 1 deletions
37
dodo.py
37
dodo.py
|
@ -1,5 +1,6 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from doit.tools import LongRunning
|
from doit.tools import LongRunning
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ from dodo_utils import wait_net_service, wait_pgsql_db, \
|
||||||
run_task_func, scan_dir
|
run_task_func, scan_dir
|
||||||
|
|
||||||
COMPOSE = 'docker-compose -p feedati'
|
COMPOSE = 'docker-compose -p feedati'
|
||||||
DOIT_CONFIG = {'default_tasks': ['up']}
|
DOIT_CONFIG = {'default_tasks': ['up'], 'backend': 'sqlite3'}
|
||||||
|
|
||||||
|
|
||||||
def task_build():
|
def task_build():
|
||||||
|
@ -104,6 +105,40 @@ def task_up():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_valid_services():
|
||||||
|
srv = subprocess.check_output((COMPOSE + ' config --services').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():
|
||||||
|
'''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, )],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def task__cleanall():
|
def task__cleanall():
|
||||||
'''clean everything there is to clean'''
|
'''clean everything there is to clean'''
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue