Merge pull request #393 from marksteve/restart

Implement restart command (Closes #98)
This commit is contained in:
Ben Firshman 2014-09-08 17:47:08 +01:00
commit ce8ef23c09
5 changed files with 37 additions and 0 deletions

View file

@ -91,6 +91,7 @@ class TopLevelCommand(Command):
scale Set number of containers for a service
start Start services
stop Stop services
restart Restart services
up Create and start containers
"""
@ -336,6 +337,14 @@ class TopLevelCommand(Command):
"""
project.stop(service_names=options['SERVICE'])
def restart(self, project, options):
"""
Restart running containers.
Usage: restart [SERVICE...]
"""
project.restart(service_names=options['SERVICE'])
def up(self, project, options):
"""
Build, (re)create, start and attach to containers for a service.

View file

@ -123,6 +123,9 @@ class Container(object):
def kill(self):
return self.client.kill(self.id)
def restart(self):
return self.client.restart(self.id)
def remove(self, **options):
return self.client.remove_container(self.id, **options)

View file

@ -156,6 +156,10 @@ class Project(object):
for service in reversed(self.get_services(service_names)):
service.kill(**options)
def restart(self, service_names=None, **options):
for service in self.get_services(service_names):
service.restart(**options)
def build(self, service_names=None, no_cache=False):
for service in self.get_services(service_names):
if service.can_be_built():

View file

@ -108,6 +108,11 @@ class Service(object):
log.info("Killing %s..." % c.name)
c.kill(**options)
def restart(self, **options):
for c in self.containers():
log.info("Restarting %s..." % c.name)
c.restart(**options)
def scale(self, desired_num):
"""
Adjusts the number of containers to the specified number and ensures they are running.