Backend host Param (#1078)
This commit is contained in:
parent
e9ca1fd03b
commit
73bf8543bd
@ -134,6 +134,9 @@ class Config(Base):
|
|||||||
# The frontend port.
|
# The frontend port.
|
||||||
backend_port: str = constants.BACKEND_PORT
|
backend_port: str = constants.BACKEND_PORT
|
||||||
|
|
||||||
|
# The backend host.
|
||||||
|
backend_host: str = constants.BACKEND_HOST
|
||||||
|
|
||||||
# The backend API url.
|
# The backend API url.
|
||||||
api_url: str = constants.API_URL
|
api_url: str = constants.API_URL
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ def run(
|
|||||||
),
|
),
|
||||||
port: str = typer.Option(None, help="Specify a different frontend port."),
|
port: str = typer.Option(None, help="Specify a different frontend port."),
|
||||||
backend_port: str = typer.Option(None, help="Specify a different backend port."),
|
backend_port: str = typer.Option(None, help="Specify a different backend port."),
|
||||||
|
backend_host: str = typer.Option(None, help="Specify the backend host."),
|
||||||
):
|
):
|
||||||
"""Run the app in the current directory."""
|
"""Run the app in the current directory."""
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
@ -83,6 +84,7 @@ def run(
|
|||||||
|
|
||||||
frontend_port = get_config().port if port is None else port
|
frontend_port = get_config().port if port is None else port
|
||||||
backend_port = get_config().backend_port if backend_port is None else backend_port
|
backend_port = get_config().backend_port if backend_port is None else backend_port
|
||||||
|
backend_host = get_config().backend_host if backend_host is None else backend_host
|
||||||
|
|
||||||
# If no --frontend-only and no --backend-only, then turn on frontend and backend both
|
# If no --frontend-only and no --backend-only, then turn on frontend and backend both
|
||||||
if not frontend and not backend:
|
if not frontend and not backend:
|
||||||
@ -126,10 +128,10 @@ def run(
|
|||||||
telemetry.send(f"run-{env.value}", get_config().telemetry_enabled)
|
telemetry.send(f"run-{env.value}", get_config().telemetry_enabled)
|
||||||
|
|
||||||
# Run the frontend and backend.
|
# Run the frontend and backend.
|
||||||
# try:
|
|
||||||
if backend:
|
if backend:
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
target=backend_cmd, args=(app.__name__, backend_port, loglevel)
|
target=backend_cmd,
|
||||||
|
args=(app.__name__, backend_host, backend_port, loglevel),
|
||||||
).start()
|
).start()
|
||||||
if frontend:
|
if frontend:
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -133,11 +133,15 @@ def run_frontend_prod(
|
|||||||
|
|
||||||
|
|
||||||
def run_backend(
|
def run_backend(
|
||||||
app_name: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR
|
app_name: str,
|
||||||
|
host: str,
|
||||||
|
port: int,
|
||||||
|
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
|
||||||
):
|
):
|
||||||
"""Run the backend.
|
"""Run the backend.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
host: The app host
|
||||||
app_name: The app name.
|
app_name: The app name.
|
||||||
port: The app port
|
port: The app port
|
||||||
loglevel: The log level.
|
loglevel: The log level.
|
||||||
@ -148,7 +152,7 @@ def run_backend(
|
|||||||
"uvicorn",
|
"uvicorn",
|
||||||
f"{app_name}:{constants.APP_VAR}.{constants.API_VAR}",
|
f"{app_name}:{constants.APP_VAR}.{constants.API_VAR}",
|
||||||
"--host",
|
"--host",
|
||||||
constants.BACKEND_HOST,
|
host,
|
||||||
"--port",
|
"--port",
|
||||||
str(port),
|
str(port),
|
||||||
"--log-level",
|
"--log-level",
|
||||||
@ -164,11 +168,15 @@ def run_backend(
|
|||||||
|
|
||||||
|
|
||||||
def run_backend_prod(
|
def run_backend_prod(
|
||||||
app_name: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR
|
app_name: str,
|
||||||
|
host: str,
|
||||||
|
port: int,
|
||||||
|
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
|
||||||
):
|
):
|
||||||
"""Run the backend.
|
"""Run the backend.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
host: The app host
|
||||||
app_name: The app name.
|
app_name: The app name.
|
||||||
port: The app port
|
port: The app port
|
||||||
loglevel: The log level.
|
loglevel: The log level.
|
||||||
@ -180,7 +188,7 @@ def run_backend_prod(
|
|||||||
[
|
[
|
||||||
*constants.RUN_BACKEND_PROD_WINDOWS,
|
*constants.RUN_BACKEND_PROD_WINDOWS,
|
||||||
"--host",
|
"--host",
|
||||||
"0.0.0.0",
|
host,
|
||||||
"--port",
|
"--port",
|
||||||
str(port),
|
str(port),
|
||||||
f"{app_name}:{constants.APP_VAR}",
|
f"{app_name}:{constants.APP_VAR}",
|
||||||
@ -189,7 +197,7 @@ def run_backend_prod(
|
|||||||
else [
|
else [
|
||||||
*constants.RUN_BACKEND_PROD,
|
*constants.RUN_BACKEND_PROD,
|
||||||
"--bind",
|
"--bind",
|
||||||
f"0.0.0.0:{port}",
|
f"{host}:{port}",
|
||||||
"--threads",
|
"--threads",
|
||||||
str(num_workers),
|
str(num_workers),
|
||||||
f"{app_name}:{constants.APP_VAR}()",
|
f"{app_name}:{constants.APP_VAR}()",
|
||||||
|
Loading…
Reference in New Issue
Block a user