瀏覽代碼

Rework 'fig up' to use recreate_containers()

Aanand Prasad 11 年之前
父節點
當前提交
5db6c9f51b
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      fig/cli/main.py

+ 9 - 5
fig/cli/main.py

@@ -220,14 +220,18 @@ class TopLevelCommand(Command):
         """
         detached = options['-d']
 
-        self.project.create_containers(service_names=options['SERVICE'])
-        containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
+        (old, new) = self.project.recreate_containers(service_names=options['SERVICE'])
 
         if not detached:
-            print("Attaching to", list_containers(containers))
-            log_printer = LogPrinter(containers)
+            to_attach = [c for (s, c) in new]
+            print("Attaching to", list_containers(to_attach))
+            log_printer = LogPrinter(to_attach)
 
-        self.project.start(service_names=options['SERVICE'])
+        for (service, container) in new:
+            service.start_container(container)
+
+        for (service, container) in old:
+            container.remove()
 
         if not detached:
             try: