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