From 6a485a225e70cae38a32521a1691f4d308621732 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 31 Dec 2019 18:30:48 -0700 Subject: [PATCH] clean up asgi initiator --- hyperglass/web.py | 28 +++++++++------------------- line_count.svg | 4 ++-- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/hyperglass/web.py b/hyperglass/web.py index 307080f..4076b73 100644 --- a/hyperglass/web.py +++ b/hyperglass/web.py @@ -1,27 +1,17 @@ -""" -Hyperglass web app initiator. Launches Sanic with appropriate number of -workers per their documentation (equal to number of CPU cores). -""" -try: - import os - import tempfile - from hyperglass import hyperglass, APP_PARAMS -except ImportError as import_error: - raise RuntimeError(import_error) +"""hyperglass web app initiator.""" def start(): - """ - Compiles configured Sass variables to CSS, then starts Sanic web - server. - """ - tempdir = tempfile.TemporaryDirectory(prefix="hyperglass_") - os.environ["prometheus_multiproc_dir"] = tempdir.name - + """Start Sanic web server.""" try: + from hyperglass import hyperglass, APP_PARAMS + hyperglass.app.run(**APP_PARAMS) - except Exception as hyperglass_error: - raise RuntimeError(hyperglass_error) + + except ImportError as import_err: + raise RuntimeError(str(import_err)) + except Exception as web_err: + raise RuntimeError(str(web_err)) app = start() diff --git a/line_count.svg b/line_count.svg index 2178915..22d6969 100644 --- a/line_count.svg +++ b/line_count.svg @@ -17,7 +17,7 @@ Lines of Code - 3202 - 3202 + 3191 + 3191 \ No newline at end of file