fix: if on macOS use uvicorn
This commit is contained in:
parent
9942efdf6d
commit
f9a049a84d
1 changed files with 13 additions and 9 deletions
|
|
@ -8,16 +8,10 @@ import typer
|
|||
from fastapi.staticfiles import StaticFiles
|
||||
from pathlib import Path
|
||||
|
||||
from langflow_backend.server import LangflowApplication
|
||||
|
||||
|
||||
def get_number_of_workers(workers=None):
|
||||
if workers is None:
|
||||
workers = (
|
||||
int(os.environ.get("OBJC_DISABLE_INITIALIZE_FORK_SAFETY", "0") == "YES")
|
||||
if platform.system() == "Darwin"
|
||||
else 1
|
||||
)
|
||||
workers = 1
|
||||
elif workers == -1:
|
||||
workers = (multiprocessing.cpu_count() * 2) + 1
|
||||
return workers
|
||||
|
|
@ -40,14 +34,24 @@ def serve(
|
|||
if not timeout:
|
||||
timeout = 60
|
||||
|
||||
host = "127.0.0.1"
|
||||
port = 5003
|
||||
options = {
|
||||
"bind": "127.0.0.1:5003",
|
||||
"bind": f"{host}:{port}",
|
||||
"workers": get_number_of_workers(workers),
|
||||
"worker_class": "uvicorn.workers.UvicornWorker",
|
||||
"timeout": timeout,
|
||||
}
|
||||
|
||||
LangflowApplication(app, options).run()
|
||||
if platform.system() == "Darwin":
|
||||
# Run using uvicorn on MacOS
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host=host, port=port, log_level="info")
|
||||
else:
|
||||
from langflow_backend.server import LangflowApplication
|
||||
|
||||
LangflowApplication(app, options).run()
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue