add missing message when running in backend_only (#4002)
* add missing message when running in backend_only * actually pass loglevel to backend_cmd
This commit is contained in:
parent
9d8b737b1a
commit
b07fba72e9
@ -247,13 +247,13 @@ def _run(
|
||||
|
||||
# In prod mode, run the backend on a separate thread.
|
||||
if backend and env == constants.Env.PROD:
|
||||
commands.append((backend_cmd, backend_host, backend_port))
|
||||
commands.append((backend_cmd, backend_host, backend_port, loglevel, frontend))
|
||||
|
||||
# Start the frontend and backend.
|
||||
with processes.run_concurrently_context(*commands):
|
||||
# In dev mode, run the backend on the main thread.
|
||||
if backend and env == constants.Env.DEV:
|
||||
backend_cmd(backend_host, int(backend_port))
|
||||
backend_cmd(backend_host, int(backend_port), loglevel, frontend)
|
||||
# The windows uvicorn bug workaround
|
||||
# https://github.com/reflex-dev/reflex/issues/2335
|
||||
if constants.IS_WINDOWS and exec.frontend_process:
|
||||
|
@ -60,6 +60,13 @@ def kill(proc_pid: int):
|
||||
process.kill()
|
||||
|
||||
|
||||
def notify_backend():
|
||||
"""Output a string notifying where the backend is running."""
|
||||
console.print(
|
||||
f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]"
|
||||
)
|
||||
|
||||
|
||||
# run_process_and_launch_url is assumed to be used
|
||||
# only to launch the frontend
|
||||
# If this is not the case, might have to change the logic
|
||||
@ -103,9 +110,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
|
||||
f"App running at: [bold green]{url}[/bold green]{' (Frontend-only mode)' if not backend_present else ''}"
|
||||
)
|
||||
if backend_present:
|
||||
console.print(
|
||||
f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]"
|
||||
)
|
||||
notify_backend()
|
||||
first_run = False
|
||||
else:
|
||||
console.print("New packages detected: Updating app...")
|
||||
@ -203,6 +208,7 @@ def run_backend(
|
||||
host: str,
|
||||
port: int,
|
||||
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
|
||||
frontend_present: bool = False,
|
||||
):
|
||||
"""Run the backend.
|
||||
|
||||
@ -210,11 +216,16 @@ def run_backend(
|
||||
host: The app host
|
||||
port: The app port
|
||||
loglevel: The log level.
|
||||
frontend_present: Whether the frontend is present.
|
||||
"""
|
||||
web_dir = get_web_dir()
|
||||
# Create a .nocompile file to skip compile for backend.
|
||||
if web_dir.exists():
|
||||
(web_dir / constants.NOCOMPILE_FILE).touch()
|
||||
|
||||
if not frontend_present:
|
||||
notify_backend()
|
||||
|
||||
# Run the backend in development mode.
|
||||
if should_use_granian():
|
||||
run_granian_backend(host, port, loglevel)
|
||||
@ -288,6 +299,7 @@ def run_backend_prod(
|
||||
host: str,
|
||||
port: int,
|
||||
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
|
||||
frontend_present: bool = False,
|
||||
):
|
||||
"""Run the backend.
|
||||
|
||||
@ -295,7 +307,11 @@ def run_backend_prod(
|
||||
host: The app host
|
||||
port: The app port
|
||||
loglevel: The log level.
|
||||
frontend_present: Whether the frontend is present.
|
||||
"""
|
||||
if not frontend_present:
|
||||
notify_backend()
|
||||
|
||||
if should_use_granian():
|
||||
run_granian_backend_prod(host, port, loglevel)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user