From 0d2deb49f94659d6af7d85c832cd1a35303b881a Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 2 Jun 2020 01:43:29 -0700 Subject: [PATCH] fix redis preflight check --- hyperglass/cli/commands.py | 23 ++++++++++++++--------- hyperglass/main.py | 5 ++--- hyperglass/util.py | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hyperglass/cli/commands.py b/hyperglass/cli/commands.py index b90d903..db9cfb2 100644 --- a/hyperglass/cli/commands.py +++ b/hyperglass/cli/commands.py @@ -69,7 +69,7 @@ def build_frontend(): return build_ui() -@hg.command( +@hg.command( # noqa: C901 "start", help=cmd_help(E.ROCKET, "Start web server", supports_color), cls=HelpColorsCommand, @@ -103,18 +103,23 @@ def start(build, direct, workers): if workers != 0: kwargs["workers"] = workers - if build: - build_complete = build_ui() + try: - if build_complete and not direct: + if build: + build_complete = build_ui() + + if build_complete and not direct: + start(**kwargs) + elif build_complete and direct: + uvicorn_start(**kwargs) + + if not build and not direct: start(**kwargs) - elif build_complete and direct: + elif not build and direct: uvicorn_start(**kwargs) - if not build and not direct: - start(**kwargs) - elif not build and direct: - uvicorn_start(**kwargs) + except Exception as err: + error(str(err)) @hg.command( diff --git a/hyperglass/main.py b/hyperglass/main.py index f7df65c..001f782 100644 --- a/hyperglass/main.py +++ b/hyperglass/main.py @@ -103,9 +103,9 @@ def on_starting(server: Arbiter): async def runner(): from asyncio import gather - await gather(check_redis_instance(), build_ui(), cache_config()) - # await log.complete() + await gather(build_ui(), cache_config()) + aiorun(check_redis_instance()) aiorun(runner()) log.success( @@ -124,7 +124,6 @@ def on_exit(server: Arbiter): async def runner(): await clear_cache() - # await log.complete() aiorun(runner()) diff --git a/hyperglass/util.py b/hyperglass/util.py index 08004c5..77f9bb4 100644 --- a/hyperglass/util.py +++ b/hyperglass/util.py @@ -520,7 +520,7 @@ async def build_frontend( # noqa: C901 migrate_static_assets(app_path) except Exception as e: - raise RuntimeError(str(e)) + raise RuntimeError(str(e)) from None return True