mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
increase default UI build timeout & add CLI option to override
This commit is contained in:
@@ -268,4 +268,4 @@ def start(**kwargs):
|
||||
try:
|
||||
uvicorn.run("hyperglass.api:app", **ASGI_PARAMS, **kwargs)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
@@ -64,13 +64,10 @@ def hg():
|
||||
@hg.command(
|
||||
"build-ui", help=cmd_help(E.BUTTERFLY, "Create a new UI build", supports_color)
|
||||
)
|
||||
def build_frontend():
|
||||
"""Create a new UI build.
|
||||
|
||||
Raises:
|
||||
click.ClickException: Raised on any errors.
|
||||
"""
|
||||
return build_ui()
|
||||
@option("-t", "--timeout", required=False, default=180, help="Timeout in seconds")
|
||||
def build_frontend(timeout):
|
||||
"""Create a new UI build."""
|
||||
return build_ui(timeout)
|
||||
|
||||
|
||||
@hg.command( # noqa: C901
|
||||
@@ -121,7 +118,7 @@ def start(build, direct, workers): # noqa: C901
|
||||
elif not build and direct:
|
||||
uvicorn_start(**kwargs)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
error("Stopping hyperglass due to keyboard interrupt.")
|
||||
|
||||
except BaseException as err:
|
||||
|
@@ -14,7 +14,7 @@ from hyperglass.cli.static import CL, NL, WS, E
|
||||
PROJECT_ROOT = Path(__file__).parent.parent
|
||||
|
||||
|
||||
def async_command(func):
|
||||
def async_command(func) -> None:
|
||||
"""Decororator for to make async functions runable from synchronous code."""
|
||||
# Standard Library
|
||||
import asyncio
|
||||
@@ -61,21 +61,17 @@ def start_web_server(start, params):
|
||||
error("Failed to start web server: {e}", e=e)
|
||||
|
||||
|
||||
def build_ui():
|
||||
"""Create a new UI build.
|
||||
|
||||
Raises:
|
||||
ClickException: Raised on any errors.
|
||||
"""
|
||||
def build_ui(timeout: int) -> None:
|
||||
"""Create a new UI build."""
|
||||
try:
|
||||
# Project
|
||||
from hyperglass.util import build_frontend
|
||||
from hyperglass.configuration import CONFIG_PATH, params, frontend_params
|
||||
from hyperglass.util.frontend import build_frontend
|
||||
from hyperglass.compat._asyncio import aiorun
|
||||
except ImportError as e:
|
||||
error("Error importing UI builder: {e}", e=e)
|
||||
|
||||
status("Starting new UI build...")
|
||||
status("Starting new UI build with a {t} second timeout...", t=timeout)
|
||||
|
||||
if params.developer_mode:
|
||||
dev_mode = "development"
|
||||
@@ -102,7 +98,7 @@ def build_ui():
|
||||
return True
|
||||
|
||||
|
||||
def create_dir(path, **kwargs):
|
||||
def create_dir(path, **kwargs) -> bool:
|
||||
"""Validate and attempt to create a directory, if it does not exist."""
|
||||
|
||||
# If input path is not a path object, try to make it one
|
||||
@@ -134,16 +130,8 @@ def create_dir(path, **kwargs):
|
||||
return True
|
||||
|
||||
|
||||
def write_to_file(file, data):
|
||||
"""Write string data to a file.
|
||||
|
||||
Arguments:
|
||||
file {Path} -- File path
|
||||
data {str} -- String data to write
|
||||
|
||||
Returns:
|
||||
{bool} -- True if successful
|
||||
"""
|
||||
def write_to_file(file, data) -> bool:
|
||||
"""Write string data to a file."""
|
||||
try:
|
||||
with file.open("w+") as f:
|
||||
f.write(data.strip())
|
||||
@@ -160,12 +148,8 @@ def write_to_file(file, data):
|
||||
return True
|
||||
|
||||
|
||||
def system_info():
|
||||
"""Create a markdown table of various system information.
|
||||
|
||||
Returns:
|
||||
{str}: Markdown table
|
||||
"""
|
||||
def system_info() -> bool:
|
||||
"""Create a markdown table of various system information."""
|
||||
# Project
|
||||
from hyperglass.util.system_info import get_system_info
|
||||
|
||||
|
Reference in New Issue
Block a user