Files
Giacomo Vercesi 3a9317d512 pypeline: factor out starlette middleware code
Factor out in a function the generation of the middleware list, to
facilitate reuse. Add the `AuthMiddleware` which allows authenticating
requests.
2026-05-22 09:04:35 +02:00

35 lines
988 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
import click
import revng.pypeline.daemon.app as app
from revng.pypeline.cli.context import ClickContext, pass_context
from revng.pypeline.cli.hypercorn import hypercorn_command, run_hypercorn
from revng.pypeline.cli.utils import PypeCommand
from revng.pypeline.daemon.daemon import Daemon
@click.command(cls=PypeCommand)
@hypercorn_command()
@pass_context
def run_daemon(ctx: ClickContext, production: bool):
"""Start the HTTP daemon."""
daemon = Daemon(
pipeline=ctx.obj.pipeline,
storage_provider_url=ctx.obj.storage_provider_url,
cache_dir=ctx.obj.cache_dir,
base_directory=ctx.obj.base_directory,
)
def on_shutdown():
assert app.shutdown_begun is not None
app.shutdown_begun.set()
return run_hypercorn(
lambda: app.make_starlette(production, daemon),
ctx.obj.hypercorn_configuration,
on_shutdown,
)