Add detached mode to run

This commit is contained in:
Ben Firshman 2013-12-20 10:53:07 +00:00
parent 2f28265d10
commit ea09ec672c
1 changed files with 18 additions and 8 deletions

View File

@ -111,7 +111,10 @@ class TopLevelCommand(Command):
""" """
Run a one-off command. Run a one-off command.
Usage: run SERVICE COMMAND [ARGS...] Usage: run [options] SERVICE COMMAND [ARGS...]
Options:
-d Detached mode: Run container in the background, print new container name
""" """
service = self.project.get_service(options['SERVICE']) service = self.project.get_service(options['SERVICE'])
if service is None: if service is None:
@ -120,6 +123,10 @@ class TopLevelCommand(Command):
'command': [options['COMMAND']] + options['ARGS'], 'command': [options['COMMAND']] + options['ARGS'],
} }
container = service.create_container(one_off=True, **container_options) container = service.create_container(one_off=True, **container_options)
if options['-d']:
service.start_container(container, ports=None)
print container.name
else:
stream = container.logs(stream=True) stream = container.logs(stream=True)
service.start_container(container, ports=None) service.start_container(container, ports=None)
for data in stream: for data in stream:
@ -131,7 +138,10 @@ class TopLevelCommand(Command):
""" """
Start all services Start all services
Usage: start [-d] Usage: start [options]
Options:
-d Detached mode: Run containers in the background, print new container names
""" """
if options['-d']: if options['-d']:
self.project.start() self.project.start()