mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
cf05ab0463
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.
52 lines
1.4 KiB
Python
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())
|