Ejemplo n.º 1
0
def run_log_printer(containers):
    r, w = os.pipe()
    reader, writer = os.fdopen(r, 'r'), os.fdopen(w, 'w')
    printer = LogPrinter(containers, output=writer)
    printer.run()
    writer.close()
    return reader.read()
Ejemplo n.º 2
0
    def start(self, services=None, logs=True, rebuild=False, **kwargs):

        project = self.project

        if rebuild:
            project.stop(services)
            project.remove_stopped(services)
            project.build(services)

        all_containers = []
        for service in project.get_services(services):
            if len(service.containers(stopped=True)) == 0:
                service.create_container()

            all_containers += service.containers(stopped=True)

        log_printer = None
        if logs:
            log_printer = LogPrinter(all_containers)

        project.start(services)

        if log_printer:
            try:
                print("Following logs from containers.")
                log_printer.run()
            except KeyboardInterrupt:
                print("Interrupted by Ctrl + C. Containers are still running. Use `ficloud stop` to stop them.")