From e01993b7f19c67b6187427e22ba85428f59b68a2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 19 Jun 2023 09:55:29 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(=5F=5Fmain=5F=5F.py):=20add?= =?UTF-8?q?=20support=20for=20running=20Langflow=20on=20Windows=20?= =?UTF-8?q?=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py):=20add=20support=20for=20?= =?UTF-8?q?running=20Langflow=20on=20MacOS=20and=20Linux=20using=20gunicor?= =?UTF-8?q?n=20The=20changes=20add=20support=20for=20running=20Langflow=20?= =?UTF-8?q?on=20Windows=20by=20using=20uvicorn=20instead=20of=20gunicorn.?= =?UTF-8?q?=20This=20is=20because=20Windows=20doesn't=20support=20gunicorn?= =?UTF-8?q?.=20The=20changes=20also=20add=20support=20for=20running=20Lang?= =?UTF-8?q?flow=20on=20MacOS=20and=20Linux=20using=20gunicorn.=20This=20is?= =?UTF-8?q?=20because=20MacOS=20requires=20an=20env=20variable=20to=20be?= =?UTF-8?q?=20set=20to=20use=20gunicorn.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 5598fb78c..29f60ed23 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -152,6 +152,17 @@ def serve( "timeout": timeout, } + if platform.system() in ["Windows"]: + # Run using uvicorn on MacOS and Windows + # Windows doesn't support gunicorn + # MacOS requires an env variable to be set to use gunicorn + run_on_windows(host, port, log_level, options, app) + else: + # Run using gunicorn on Linux + run_on_mac_or_linux(host, port, log_level, options, app, open_browser) + + +def run_on_mac_or_linux(host, port, log_level, options, app, open_browser=True): webapp_process = Process( target=run_langflow, args=(host, port, log_level, options, app) ) @@ -169,6 +180,14 @@ def serve( webbrowser.open(f"http://{host}:{port}") +def run_on_windows(host, port, log_level, options, app): + """ + Run the Langflow server on Windows. + """ + print_banner(host, port) + run_langflow(host, port, log_level, options, app) + + def setup_static_files(app: FastAPI, static_files_dir: Path): """ Setup the static files directory.