Use stream_logs for frontend process (#1682)

This commit is contained in:
Nikhil Rao 2023-08-25 16:16:51 -07:00 committed by GitHub
parent 3916668461
commit 6bfce48b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 26 deletions

View File

@ -25,9 +25,7 @@ def start_watching_assets_folder(root):
asset_watch.start() asset_watch.start()
def run_process_and_launch_url( def run_process_and_launch_url(run_command: list[str]):
run_command: list[str],
):
"""Run the process and launch the URL. """Run the process and launch the URL.
Args: Args:
@ -37,19 +35,13 @@ def run_process_and_launch_url(
run_command, cwd=constants.WEB_DIR, shell=constants.IS_WINDOWS run_command, cwd=constants.WEB_DIR, shell=constants.IS_WINDOWS
) )
if process.stdout: for line in processes.stream_logs("Starting frontend", process):
for line in process.stdout:
if "ready started server on" in line: if "ready started server on" in line:
url = line.split("url: ")[-1].strip() url = line.split("url: ")[-1].strip()
console.print(f"App running at: [bold green]{url}") console.print(f"App running at: [bold green]{url}")
else:
console.debug(line)
def run_frontend( def run_frontend(root: Path, port: str):
root: Path,
port: str,
):
"""Run the frontend. """Run the frontend.
Args: Args:
@ -67,10 +59,7 @@ def run_frontend(
run_process_and_launch_url([prerequisites.get_package_manager(), "run", "dev"]) # type: ignore run_process_and_launch_url([prerequisites.get_package_manager(), "run", "dev"]) # type: ignore
def run_frontend_prod( def run_frontend_prod(root: Path, port: str):
root: Path,
port: str,
):
"""Run the frontend. """Run the frontend.
Args: Args:

View File

@ -193,10 +193,7 @@ def run_concurrently(*fns: Union[Callable, Tuple]) -> None:
pass pass
def stream_logs( def stream_logs(message: str, process: subprocess.Popen):
message: str,
process: subprocess.Popen,
):
"""Stream the logs for a process. """Stream the logs for a process.
Args: Args:
@ -228,10 +225,7 @@ def stream_logs(
raise typer.Exit(1) raise typer.Exit(1)
def show_logs( def show_logs(message: str, process: subprocess.Popen):
message: str,
process: subprocess.Popen,
):
"""Show the logs for a process. """Show the logs for a process.
Args: Args: