Esempio n. 1
0
def cli(fake_settings_class: Type[BaseCustomSettings]) -> typer.Typer:
    main = typer.Typer(name="app")

    @main.command()
    def run():
        """Emulates run"""
        typer.secho("Starting app ... ")
        typer.secho("Resolving settings ...", nl=False)
        typer.secho("DONE", fg=typer.colors.GREEN)

    # adds settings command
    settings_cmd = create_settings_command(fake_settings_class, log)
    main.command()(settings_cmd)

    return main
Esempio n. 2
0
    app = create_application()
    return (app, config)


async def app_factory() -> web.Application:
    """Created to launch app from gunicorn (see docker/boot.sh)"""
    app_settings = ApplicationSettings()
    assert app_settings.SC_BUILD_TARGET  # nosec

    log.info("Application settings: %s",
             app_settings.json(indent=2, sort_keys=True))

    app, _ = _setup_app_from_settings(app_settings)

    return app


# CLI -------------

main = typer.Typer(name="simcore-service-webserver")

main.command()(create_settings_command(settings_cls=ApplicationSettings,
                                       logger=log))


@main.command()
def run():
    app_settings = ApplicationSettings()
    app, cfg = _setup_app_from_settings(app_settings)
    run_service(app, cfg)
Esempio n. 3
0
import logging

import typer
from settings_library.utils_cli import create_settings_command

from . import application
from .settings import Settings

LOG_LEVEL_STEP = logging.CRITICAL - logging.ERROR

log = logging.getLogger(__name__)

main = typer.Typer(name="simcore-service-storage service")

main.command()(create_settings_command(settings_cls=Settings, logger=log))


@main.command()
def run():
    """Runs application"""
    typer.secho("Resolving settings ...", nl=False)
    settings_obj = Settings.create_from_envs()
    typer.secho("DONE", fg=typer.colors.GREEN)

    logging.basicConfig(level=settings_obj.log_level)
    logging.root.setLevel(settings_obj.log_level)

    # keep mostly quiet noisy loggers
    quiet_level: int = max(
        min(logging.root.level + LOG_LEVEL_STEP, logging.CRITICAL),
        logging.WARNING)