Răsfoiți Sursa

Windows production mode command (#570)

PeterYusuke 2 ani în urmă
părinte
comite
f7a5c99969
2 a modificat fișierele cu 26 adăugiri și 8 ștergeri
  1. 1 0
      pynecone/constants.py
  2. 25 8
      pynecone/utils.py

+ 1 - 0
pynecone/constants.py

@@ -77,6 +77,7 @@ BACKEND_HOST = "0.0.0.0"
 TIMEOUT = 120
 # The command to run the backend in production mode.
 RUN_BACKEND_PROD = f"gunicorn --worker-class uvicorn.workers.UvicornH11Worker --preload --timeout {TIMEOUT} --log-level critical".split()
+RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {TIMEOUT}".split()
 
 # Compiler variables.
 # The extension for compiled Javascript files.

+ 25 - 8
pynecone/utils.py

@@ -799,16 +799,33 @@ def run_backend_prod(
     setup_backend()
 
     num_workers = get_num_workers()
-    command = constants.RUN_BACKEND_PROD + [
-        "--bind",
-        f"0.0.0.0:{port}",
+    command = (
+        constants.RUN_BACKEND_PROD_WINDOWS
+        + [
+            "--host",
+            "0.0.0.0",
+            "--port",
+            str(port),
+            "--log-level",
+            loglevel,
+            f"{app_name}:{constants.APP_VAR}",
+        ]
+        if platform.system() == "Windows"
+        else constants.RUN_BACKEND_PROD
+        + [
+            "--bind",
+            f"0.0.0.0:{port}",
+            "--threads",
+            str(num_workers),
+            "--log-level",
+            str(loglevel),
+            f"{app_name}:{constants.APP_VAR}()",
+        ]
+    )
+
+    command += [
         "--workers",
         str(num_workers),
-        "--threads",
-        str(num_workers),
-        "--log-level",
-        str(loglevel),
-        f"{app_name}:{constants.APP_VAR}()",
     ]
     subprocess.run(command)