Files
revng-revng/python/revng/cli/daemon.py
T
Giacomo Vercesi cf05ab0463 Substitute Flask with Starlette
In the future we will need to use GraphQL subscriptions. This is done
via websockets and is supported in Ariadne. However this support is
limited to ASGI frameworks, which Flask isn't a part of.
Startlette is a direct depencency of Ariadne, and all of Ariadne's
features are fully integrated with Starlette, so the switch allows to
drop some Flask integration cruft and streamline the revng.daemon
package.
2022-05-03 10:57:21 +02:00

52 lines
1.4 KiB
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
import os
from sys import executable as py_executable
from .commands_registry import Command, Options, commands_registry
from .support import collect_files, collect_libraries, run
class DaemonCommand(Command):
def __init__(self):
super().__init__(("daemon",), "Run revng GraphQL server")
def register_arguments(self, parser):
parser.add_argument("-p", "--port", type=str)
def run(self, options: Options):
libraries, _ = collect_libraries(options.search_prefixes)
pipelines = collect_files(options.search_prefixes, ["share", "revng", "pipelines"], "*.yml")
if options.parsed_args.port is not None:
port = options.parsed_args.port
else:
port = "8000"
env = {
**os.environ,
"REVNG_ANALYSIS_LIBRARIES": ":".join(libraries),
"REVNG_PIPELINES": ",".join(pipelines),
"STARLETTE_DEBUG": "1",
}
return run(
[
py_executable,
"-m",
"hypercorn",
"-b",
f"127.0.0.1:{port}",
"-k",
"asyncio",
"revng.daemon:app",
],
options,
env,
True,
)
commands_registry.register_command(DaemonCommand())