mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
3a9317d512
Factor out in a function the generation of the middleware list, to facilitate reuse. Add the `AuthMiddleware` which allows authenticating requests.
35 lines
988 B
Python
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,
|
|
)
|