Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
ecd1cc31dc
commit
3a0153859a
3 changed files with 75 additions and 14 deletions
|
|
@ -538,19 +538,8 @@ class TopLevelCommand(Command):
|
|||
)
|
||||
|
||||
if not detached:
|
||||
print("Attaching to", list_containers(to_attach))
|
||||
log_printer = LogPrinter(to_attach, attach_params={"logs": True}, monochrome=monochrome)
|
||||
|
||||
try:
|
||||
log_printer.run()
|
||||
finally:
|
||||
def handler(signal, frame):
|
||||
project.kill(service_names=service_names)
|
||||
sys.exit(0)
|
||||
signal.signal(signal.SIGINT, handler)
|
||||
|
||||
print("Gracefully stopping... (press Ctrl+C again to force)")
|
||||
project.stop(service_names=service_names, timeout=timeout)
|
||||
log_printer = build_log_printer(to_attach, service_names, monochrome)
|
||||
attach_to_logs(project, log_printer, service_names, timeout)
|
||||
|
||||
def migrate_to_labels(self, project, _options):
|
||||
"""
|
||||
|
|
@ -593,5 +582,26 @@ class TopLevelCommand(Command):
|
|||
print(get_version_info('full'))
|
||||
|
||||
|
||||
def build_log_printer(containers, service_names, monochrome):
|
||||
return LogPrinter(
|
||||
[c for c in containers if c.service in service_names],
|
||||
attach_params={"logs": True},
|
||||
monochrome=monochrome)
|
||||
|
||||
|
||||
def attach_to_logs(project, log_printer, service_names, timeout):
|
||||
print("Attaching to", list_containers(log_printer.containers))
|
||||
try:
|
||||
log_printer.run()
|
||||
finally:
|
||||
def handler(signal, frame):
|
||||
project.kill(service_names=service_names)
|
||||
sys.exit(0)
|
||||
signal.signal(signal.SIGINT, handler)
|
||||
|
||||
print("Gracefully stopping... (press Ctrl+C again to force)")
|
||||
project.stop(service_names=service_names, timeout=timeout)
|
||||
|
||||
|
||||
def list_containers(containers):
|
||||
return ", ".join(c.name for c in containers)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue