Exemplo n.º 1
0
def _updateserver():
    logging.info("Starting Orchest update service")

    container_image = "orchest/update-server:latest"
    container_spec = CONTAINER_MAPPING.get(container_image, {})
    run_config = utils.convert_to_run_config(container_image, container_spec)

    logging.info("Starting image %s" % container_image)
    docker_client.containers.run(**run_config)
Exemplo n.º 2
0
def start():
    # Make sure the installation is complete before starting Orchest.
    if not utils.is_install_complete(language="none"):
        typer.echo("Installation required. To install Orchest run:")
        typer.echo("\torchest install")
        return

    # Dynamically mount certs directory based on whether it exists in
    # nginx-proxy directory on host
    if proxy_certs_exist_on_host():
        CONTAINER_MAPPING["orchest/nginx-proxy:latest"]["mounts"].append({
            "source":
            os.path.join(config.ENVS["HOST_REPO_DIR"], "services",
                         "nginx-proxy", "certs"),
            "target":
            "/etc/ssl/certs",
        })
    else:
        # in case no certs are found don't expose 443 on host
        del CONTAINER_MAPPING["orchest/nginx-proxy:latest"]["ports"]["443/tcp"]

    if config.RUN_MODE == "dev":
        logging.info(
            "Starting Orchest in DEV mode. This mounts host directories "
            "to monitor for source code changes.")

        utils.dev_mount_inject(CONTAINER_MAPPING)
    else:
        typer.echo("[Start]: ...")

    # Clean up lingering, old images from previous starts.
    utils.clean_containers()

    # TODO: is the repo tag always the first tag in the Docker
    #       Engine API?
    # Determine the containers that are already running as we do not
    # want to run these again.
    running_containers = docker_client.containers.list()
    running_container_images = [
        running_container.image.tags[0]
        for running_container in running_containers
        if len(running_container.image.tags) > 0
    ]

    images_to_start = [
        image_name for image_name in config.ON_START_IMAGES
        if image_name not in running_container_images
    ]

    # Run every container that is not already running. Additionally,
    # use pre-defined container specifications if the container has
    # any.
    for container_image in images_to_start:
        container_spec = CONTAINER_MAPPING.get(container_image, {})
        run_config = utils.convert_to_run_config(container_image,
                                                 container_spec)

        logging.info("Starting image %s" % container_image)
        docker_client.containers.run(**run_config)

    utils.log_server_url()
Exemplo n.º 3
0
def start():
    # Make sure the installation is complete before starting Orchest.
    if not utils.is_install_complete(language="none"):
        typer.echo("Installation required. To install Orchest run:")
        typer.echo("\torchest install")
        return

    # Dynamically mount certs directory based on whether it exists in
    # nginx-proxy directory on host
    if proxy_certs_exist_on_host():
        CONTAINER_MAPPING["orchest/nginx-proxy:latest"]["mounts"].append(
            {
                "source": os.path.join(
                    config.ENVS["HOST_REPO_DIR"], "services", "nginx-proxy", "certs"
                ),
                "target": "/etc/ssl/certs",
            }
        )
    else:
        # in case no certs are found don't expose 443 on host
        del CONTAINER_MAPPING["orchest/nginx-proxy:latest"]["ports"]["443/tcp"]

    if config.RUN_MODE == "dev":
        logging.info(
            "Starting Orchest in DEV mode. This mounts host directories "
            "to monitor for source code changes."
        )

        utils.dev_mount_inject(CONTAINER_MAPPING)
    else:
        typer.echo("[Start]: ...")

    # Clean up lingering, old images from previous starts.
    utils.clean_containers()

    # Make sure userdir/ permissions are correct
    utils.fix_userdir_permissions()

    # TODO: is the repo tag always the first tag in the Docker
    #       Engine API?
    # Determine the containers that are already running as we do not
    # want to run these again.
    running_containers = docker_client.containers.list()
    running_container_images = [
        running_container.image.tags[0]
        for running_container in running_containers
        if len(running_container.image.tags) > 0
    ]

    images_to_start = [
        image_name
        for image_name in config.ON_START_IMAGES
        if image_name not in running_container_images
    ]

    # Run every container that is not already running. Additionally,
    # use pre-defined container specifications if the container has
    # any.
    for container_image in images_to_start:
        container_spec = CONTAINER_MAPPING.get(container_image, {})
        run_config = utils.convert_to_run_config(container_image, container_spec)

        logging.info("Starting image %s" % container_image)
        container = docker_client.containers.run(**run_config)

        # wait for the db to be accepting connections before launching
        # other containers, this will likely take 1 try or two.
        # TODO: should we have a generic abstraction when it comes to
        # dependencies among the services? I don't think it's needed.
        if container_image.startswith("postgres"):
            exit_code, _ = container.exec_run("pg_isready --username postgres")
            while exit_code != 0:
                exit_code, _ = container.exec_run("pg_isready --username postgres")
                time.sleep(1)

    utils.log_server_url()