Skip to content

Commit 9d55e01

Browse files
committed
Implement restart command (Closes #98)
Signed-off-by: Mark Steve Samson <hello@marksteve.com>
1 parent 22f897e commit 9d55e01

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

fig/cli/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class TopLevelCommand(Command):
9090
scale Set number of containers for a service
9191
start Start services
9292
stop Stop services
93+
restart Restart services
9394
up Create and start containers
9495
9596
"""
@@ -315,6 +316,14 @@ def stop(self, project, options):
315316
"""
316317
project.stop(service_names=options['SERVICE'])
317318

319+
def restart(self, project, options):
320+
"""
321+
Restart running containers.
322+
323+
Usage: restart [SERVICE...]
324+
"""
325+
project.restart(service_names=options['SERVICE'])
326+
318327
def up(self, project, options):
319328
"""
320329
Build, (re)create, start and attach to containers for a service.

fig/container.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ def stop(self, **options):
117117
def kill(self):
118118
return self.client.kill(self.id)
119119

120+
def restart(self):
121+
return self.client.restart(self.id)
122+
120123
def remove(self, **options):
121124
return self.client.remove_container(self.id, **options)
122125

fig/project.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ def kill(self, service_names=None, **options):
155155
for service in reversed(self.get_services(service_names)):
156156
service.kill(**options)
157157

158+
def restart(self, service_names=None, **options):
159+
for service in self.get_services(service_names):
160+
service.restart(**options)
161+
158162
def build(self, service_names=None, no_cache=False):
159163
for service in self.get_services(service_names):
160164
if service.can_be_built():

fig/service.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def kill(self, **options):
8989
log.info("Killing %s..." % c.name)
9090
c.kill(**options)
9191

92+
def restart(self, **options):
93+
for c in self.containers():
94+
log.info("Restarting %s..." % c.name)
95+
c.restart(**options)
96+
9297
def scale(self, desired_num):
9398
"""
9499
Adjusts the number of containers to the specified number and ensures they are running.

0 commit comments

Comments
 (0)