diff --git a/compose/cli/log_printer.py b/compose/cli/log_printer.py index 367a534e..b48462ff 100644 --- a/compose/cli/log_printer.py +++ b/compose/cli/log_printer.py @@ -88,7 +88,10 @@ class LogPrinter(object): if not line: if not thread_map: + # There are no running containers left to tail, so exit return + # We got an empty line because of a timeout, but there are still + # active containers to tail, so continue continue self.output.write(line) diff --git a/compose/cli/main.py b/compose/cli/main.py index 468e10c4..52b4a03b 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -389,7 +389,7 @@ class TopLevelCommand(object): } print("Attaching to", list_containers(containers)) log_printer_from_project( - project, + self.project, containers, options['--no-color'], log_args).run() @@ -708,10 +708,7 @@ class TopLevelCommand(object): raise UserError("--abort-on-container-exit and -d cannot be combined.") with up_shutdown_context(self.project, service_names, timeout, detached): - # start the event stream first so we don't lose any events - event_stream = project.events(service_names=service_names) - - to_attach = project.up( + to_attach = self.project.up( service_names=service_names, start_deps=start_deps, strategy=convergence_strategy_from_opts(options), @@ -723,12 +720,12 @@ class TopLevelCommand(object): return log_printer = log_printer_from_project( - project, + self.project, filter_containers_to_service_names(to_attach, service_names), options['--no-color'], {'follow': True}, cascade_stop, - event_stream=event_stream) + event_stream=self.project.events(service_names=service_names)) print("Attaching to", list_containers(log_printer.containers)) log_printer.run() diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 095fb3f1..ab74f14e 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -396,8 +396,8 @@ class CLITestCase(DockerClientTestCase): self.base_dir = 'tests/fixtures/echo-services' result = self.dispatch(['up', '--no-color']) - assert 'simple_1 | simple' in result.stdout - assert 'another_1 | another' in result.stdout + assert 'simple_1 | simple' in result.stdout + assert 'another_1 | another' in result.stdout assert 'simple_1 exited with code 0' in result.stdout assert 'another_1 exited with code 0' in result.stdout