1
- import multiprocessing
2
1
import platform
3
2
import socket
4
3
import sys
5
- import time
6
- import webbrowser
7
4
from pathlib import Path
8
5
from typing import Optional
9
6
10
- import httpx
11
7
import typer
12
8
from dotenv import load_dotenv
13
- from multiprocess import Process , cpu_count # type: ignore
9
+ from multiprocess import cpu_count # type: ignore
14
10
from rich import box
15
11
from rich import print as rprint
16
12
from rich .console import Console
17
13
from rich .panel import Panel
18
14
from rich .table import Table
15
+ from sqlmodel import select
19
16
20
17
from langflow .main import setup_app
21
- from langflow .services .deps import get_settings_service
22
- from langflow .services .utils import initialize_settings_service
18
+ from langflow .services .database .utils import session_getter
19
+ from langflow .services .deps import get_db_service , get_settings_service
20
+ from langflow .services .utils import initialize_services , initialize_settings_service
23
21
from langflow .utils .logger import configure , logger
24
22
25
23
console = Console ()
@@ -211,28 +209,12 @@ def run(
211
209
run_on_windows (host , port , log_level , options , app )
212
210
else :
213
211
# Run using gunicorn on Linux
214
- run_on_mac_or_linux (host , port , log_level , options , platform . system (), open_browser )
212
+ run_on_mac_or_linux (host , port , log_level , options , app )
215
213
216
214
217
- def run_on_mac_or_linux (host , port , log_level , options , system , open_browser = True ):
218
- if system == "Darwin" :
219
- ctx = multiprocessing .get_context ("spawn" )
220
- webapp_process = ctx .Process (target = run_langflow , args = (host , port , log_level , options ))
221
- else :
222
- webapp_process = Process (target = run_langflow , args = (host , port , log_level , options ))
223
- webapp_process .start ()
224
- status_code = 0
225
- while status_code != 200 :
226
- try :
227
- status_code = httpx .get (f"http://{ host } :{ port } /health" ).status_code
228
-
229
- except Exception :
230
- time .sleep (1 )
231
-
215
+ def run_on_mac_or_linux (host , port , log_level , options , app ):
232
216
print_banner (host , port )
233
- if open_browser :
234
- webbrowser .open (f"http://{ host } :{ port } " )
235
- webapp_process .join ()
217
+ run_langflow (host , port , log_level , options , app )
236
218
237
219
238
220
def run_on_windows (host , port , log_level , options , app ):
@@ -302,7 +284,7 @@ def print_banner(host, port):
302
284
rprint (panel )
303
285
304
286
305
- def run_langflow (host , port , log_level , options ):
287
+ def run_langflow (host , port , log_level , options , app ):
306
288
"""
307
289
Run Langflow server on localhost
308
290
"""
@@ -315,12 +297,10 @@ def run_langflow(host, port, log_level, options):
315
297
import uvicorn
316
298
317
299
uvicorn .run (
318
- "langflow.main:create_app" ,
319
- factory = True ,
300
+ app ,
320
301
host = host ,
321
302
port = port ,
322
303
log_level = log_level ,
323
- workers = options ["workers" ],
324
304
)
325
305
else :
326
306
from langflow .server import LangflowApplication
0 commit comments