async def project_stop_impl(subject: ReplaySubject, project_name: str, services: List[str]):
    try:
        project = load_single_project(project_name).config
    except GraphQLError as ex:
        subject.on_next(StartStopEndStep(
            error_string=str(ex),
            is_fatal_error=True
        ))
        subject.on_completed()
        return
    engine = registry().engine

    if len(services) < 1:
        services = project["app"]["services"].keys()

    last_steps: Dict[str, int] = {}

    try:
        async for service_name, status, finished in engine.stop_project(project, services):
            _handle_update(finished, last_steps, service_name, status, subject, "Service stopped!")
    except Exception as err:
        print(traceback.format_exc())
        subject.on_next(StartStopEndStep(
            error_string="Error stopping the services: " + str(err),
            is_fatal_error=True
        ))
    else:
        subject.on_next(StartStopEndStep())

    subject.on_completed()
Пример #2
0
async def update_repositories_impl(subject: ReplaySubject):
    subject.on_next(ResultStep(
        steps=2,
        current_step=1,
        text="Starting repository update..."
    ))
    try:
        repositories.update(registry().system_config, lambda msg: subject.on_next(ResultStep(
            steps=2,
            current_step=1,
            text=msg
        )))
    except Exception as e:
        subject.on_next(ResultStep(
            steps=2,
            current_step=1,
            text="Fatal error during repository update: " + str(e),
            is_end=True,
            is_error=True
        ))
        subject.on_completed()
        return
    subject.on_next(ResultStep(
        steps=2,
        current_step=2,
        text="Reloading configuration..."
    ))

    # Reload system config
    try:
        config_path = riptide_main_config_file()
        system_config = Config.from_yaml(config_path)
        system_config.validate()
        registry.system_config = system_config
    except FileNotFoundError as e:
        subject.on_next(ResultStep(
            steps=2,
            current_step=2,
            text="Main config file not found! Could not reload system config.",
            is_end=True,
            is_error=True
        ))
    except Exception as e:
        subject.on_next(ResultStep(
            steps=2,
            current_step=2,
            text="Could not reload system config: " + str(e),
            is_end=True,
            is_error=True
        ))
    else:
        subject.on_next(ResultStep(
            steps=2,
            current_step=2,
            text="Repository update done!",
            is_end=True
        ))
    finally:
        subject.on_completed()
Пример #3
0
async def update_images_impl(subject: ReplaySubject, project_name: str):
    subject.on_next(ResultStep(
        steps=1,
        current_step=1,
        text="Starting image update..."
    ))

    project = try_loading_project(project_name, subject, 1, 1)
    if not project:
        return

    try:
        registry().engine.pull_images(project,
                                      line_reset="",
                                      update_func=lambda msg: subject.on_next(
                                          ResultStep(
                                            steps=1,
                                            current_step=1,
                                            text=msg
                                          )
                                      ))
        subject.on_next(ResultStep(
            steps=1,
            current_step=1,
            text="Done updating images!",
            is_end=True
        ))
    except Exception as ex:
        subject.on_next(ResultStep(
            steps=1,
            current_step=1,
            text="Error updating an image: " + str(ex),
            is_end=True,
            is_error=True
        ))
    finally:
        subject.on_completed()
    pass