1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00
Files
checktheroads-hyperglass/hyperglass/web.py
2019-12-30 09:43:49 -07:00

28 lines
694 B
Python

"""
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)
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
try:
hyperglass.app.run(**APP_PARAMS)
except Exception as hyperglass_error:
raise RuntimeError(hyperglass_error)
app = start()