🐛 fix(__main__.py): set OBJC_DISABLE_INITIALIZE_FORK_SAFETY environment variable on MacOS to avoid error when running gunicorn

 feat(__main__.py): load environment variables from .env file to override existing environment variables
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-10-04 12:48:30 -03:00
commit e72c04a94a

View file

@ -52,6 +52,18 @@ def display_results(results):
console.print() # Print a new line
def set_var_for_macos_issue():
# OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
# we need to set this var is we are running on MacOS
# otherwise we get an error when running gunicorn
if platform.system() in ["Darwin"]:
import os
os.environ["OBJC_DISABLE_INITIALIZE_FORK_SAFETY"] = "YES"
logger.debug("Set OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES to avoid error")
def update_settings(
config: str,
cache: Optional[str] = None,
@ -143,7 +155,10 @@ def run(
"""
Run the Langflow.
"""
set_var_for_macos_issue()
# override env variables with .env file
if env_file:
load_dotenv(env_file, override=True)
@ -165,7 +180,6 @@ def run(
options = {
"bind": f"{host}:{port}",
"workers": get_number_of_workers(workers),
"worker_class": "uvicorn.workers.UvicornWorker",
"timeout": timeout,
}