Merge branch 'dev' of https://github.com/logspace-ai/langflow into dev
This commit is contained in:
commit
ffe5989bce
1 changed files with 23 additions and 8 deletions
|
|
@ -1,11 +1,20 @@
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
|
||||||
from langflow_backend.main import create_app
|
from langflow_backend.main import create_app
|
||||||
|
|
||||||
import typer
|
import typer
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from langflow_backend.server import LangflowApplication
|
|
||||||
|
def get_number_of_workers(workers=None):
|
||||||
|
if workers is None:
|
||||||
|
workers = 1
|
||||||
|
elif workers == -1:
|
||||||
|
workers = (multiprocessing.cpu_count() * 2) + 1
|
||||||
|
return workers
|
||||||
|
|
||||||
|
|
||||||
def serve(
|
def serve(
|
||||||
|
|
@ -21,21 +30,27 @@ def serve(
|
||||||
StaticFiles(directory=static_files_dir, html=True),
|
StaticFiles(directory=static_files_dir, html=True),
|
||||||
name="static",
|
name="static",
|
||||||
)
|
)
|
||||||
if not workers:
|
|
||||||
workers = 1
|
|
||||||
elif workers == -1:
|
|
||||||
workers = (multiprocessing.cpu_count() * 2) + 1
|
|
||||||
|
|
||||||
if not timeout:
|
if not timeout:
|
||||||
timeout = 60
|
timeout = 60
|
||||||
|
|
||||||
|
host = "127.0.0.1"
|
||||||
|
port = 5003
|
||||||
options = {
|
options = {
|
||||||
"bind": "127.0.0.1:5003",
|
"bind": f"{host}:{port}",
|
||||||
"workers": workers,
|
"workers": get_number_of_workers(workers),
|
||||||
"worker_class": "uvicorn.workers.UvicornWorker",
|
"worker_class": "uvicorn.workers.UvicornWorker",
|
||||||
"timeout": timeout,
|
"timeout": timeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
LangflowApplication(app, options).run()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue