Procházet zdrojové kódy

Fix run frontend only (#1706)

Nikhil Rao před 1 rokem
rodič
revize
1372042228
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  1. 8 1
      reflex/reflex.py

+ 8 - 1
reflex/reflex.py

@@ -170,13 +170,20 @@ def run(
 
 
     # Run the frontend and backend together.
     # Run the frontend and backend together.
     commands = []
     commands = []
+
+    # 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))
+
+    # In prod mode, run the backend on a separate thread.
     if backend and env == constants.Env.PROD:
     if backend and env == constants.Env.PROD:
         commands.append((backend_cmd, backend_host, backend_port))
         commands.append((backend_cmd, backend_host, backend_port))
+
+    # Start the frontend and backend.
     with processes.run_concurrently_context(*commands):
     with processes.run_concurrently_context(*commands):
-        if env == constants.Env.DEV:
+        # 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))