Windows --frontend-only
fix ctrl + c (#3181)
This commit is contained in:
parent
c636c91c9c
commit
db47d39979
@ -212,7 +212,7 @@ def _run(
|
|||||||
# Run the frontend on a separate thread.
|
# Run the frontend on a separate thread.
|
||||||
if frontend:
|
if frontend:
|
||||||
setup_frontend(Path.cwd())
|
setup_frontend(Path.cwd())
|
||||||
commands.append((frontend_cmd, Path.cwd(), frontend_port))
|
commands.append((frontend_cmd, Path.cwd(), frontend_port, backend))
|
||||||
|
|
||||||
# In prod mode, run the backend on a separate thread.
|
# In prod mode, run the backend on a separate thread.
|
||||||
if backend and env == constants.Env.PROD:
|
if backend and env == constants.Env.PROD:
|
||||||
|
@ -73,11 +73,12 @@ def kill(proc_pid: int):
|
|||||||
# run_process_and_launch_url is assumed to be used
|
# run_process_and_launch_url is assumed to be used
|
||||||
# only to launch the frontend
|
# only to launch the frontend
|
||||||
# If this is not the case, might have to change the logic
|
# If this is not the case, might have to change the logic
|
||||||
def run_process_and_launch_url(run_command: list[str]):
|
def run_process_and_launch_url(run_command: list[str], backend_present=True):
|
||||||
"""Run the process and launch the URL.
|
"""Run the process and launch the URL.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
run_command: The command to run.
|
run_command: The command to run.
|
||||||
|
backend_present: Whether the backend is present.
|
||||||
"""
|
"""
|
||||||
from reflex.utils import processes
|
from reflex.utils import processes
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ def run_process_and_launch_url(run_command: list[str]):
|
|||||||
while True:
|
while True:
|
||||||
if process is None:
|
if process is None:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if constants.IS_WINDOWS:
|
if constants.IS_WINDOWS and backend_present:
|
||||||
kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore
|
kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore
|
||||||
process = processes.new_process(
|
process = processes.new_process(
|
||||||
run_command,
|
run_command,
|
||||||
@ -122,12 +123,13 @@ def run_process_and_launch_url(run_command: list[str]):
|
|||||||
break # while True
|
break # while True
|
||||||
|
|
||||||
|
|
||||||
def run_frontend(root: Path, port: str):
|
def run_frontend(root: Path, port: str, backend_present=True):
|
||||||
"""Run the frontend.
|
"""Run the frontend.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
root: The root path of the project.
|
root: The root path of the project.
|
||||||
port: The port to run the frontend on.
|
port: The port to run the frontend on.
|
||||||
|
backend_present: Whether the backend is present.
|
||||||
"""
|
"""
|
||||||
from reflex.utils import prerequisites
|
from reflex.utils import prerequisites
|
||||||
|
|
||||||
@ -139,15 +141,19 @@ def run_frontend(root: Path, port: str):
|
|||||||
# Run the frontend in development mode.
|
# Run the frontend in development mode.
|
||||||
console.rule("[bold green]App Running")
|
console.rule("[bold green]App Running")
|
||||||
os.environ["PORT"] = str(get_config().frontend_port if port is None else port)
|
os.environ["PORT"] = str(get_config().frontend_port if port is None else port)
|
||||||
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
|
||||||
|
backend_present,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_frontend_prod(root: Path, port: str):
|
def run_frontend_prod(root: Path, port: str, backend_present=True):
|
||||||
"""Run the frontend.
|
"""Run the frontend.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
root: The root path of the project (to keep same API as run_frontend).
|
root: The root path of the project (to keep same API as run_frontend).
|
||||||
port: The port to run the frontend on.
|
port: The port to run the frontend on.
|
||||||
|
backend_present: Whether the backend is present.
|
||||||
"""
|
"""
|
||||||
from reflex.utils import prerequisites
|
from reflex.utils import prerequisites
|
||||||
|
|
||||||
@ -157,7 +163,10 @@ def run_frontend_prod(root: Path, port: str):
|
|||||||
prerequisites.validate_frontend_dependencies(init=False)
|
prerequisites.validate_frontend_dependencies(init=False)
|
||||||
# Run the frontend in production mode.
|
# Run the frontend in production mode.
|
||||||
console.rule("[bold green]App Running")
|
console.rule("[bold green]App Running")
|
||||||
run_process_and_launch_url([prerequisites.get_package_manager(), "run", "prod"]) # type: ignore
|
run_process_and_launch_url(
|
||||||
|
[prerequisites.get_package_manager(), "run", "prod"], # type: ignore
|
||||||
|
backend_present,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_backend(
|
def run_backend(
|
||||||
|
Loading…
Reference in New Issue
Block a user