@@ -402,6 +402,13 @@ def run(
402402 None , help = "Defines the SSL certificate file path." , show_default = False
403403 ),
404404 ssl_key_file_path : str | None = typer .Option (None , help = "Defines the SSL key file path." , show_default = False ),
405+ deployment_profile : str | None = typer .Option ( # noqa: ARG001 — applied to settings via the CLI-arg loop below
406+ None ,
407+ help = "Deployment profile: 'dev' (default) or 'prod'. 'prod' runs fail-loud "
408+ "production infrastructure checks before starting and aborts boot if a required "
409+ "service is missing. Can also be set via LANGFLOW_DEPLOYMENT_PROFILE." ,
410+ show_default = False ,
411+ ),
405412) -> None :
406413 """Run Langflow."""
407414 if env_file :
@@ -470,6 +477,24 @@ def run(
470477 # create path object if frontend_path is provided
471478 static_files_dir : Path | None = Path (frontend_path ) if frontend_path else None
472479
480+ # Propagate the resolved profile to the environment so forked Gunicorn workers
481+ # and factory-based entrypoints (which rebuild settings from env) observe it —
482+ # this carries a --deployment-profile CLI flag through to the app factory.
483+ resolved_profile = get_settings_service ().settings .deployment_profile
484+ os .environ ["LANGFLOW_DEPLOYMENT_PROFILE" ] = resolved_profile
485+
486+ # Production preflight: fail-loud infrastructure checks. Runs once here in the
487+ # parent process, before any worker is spawned, so a misconfigured prod
488+ # deployment aborts cleanly instead of coming up half-working. The FastAPI
489+ # lifespan runs the same check as a safety net for entrypoints that bypass this
490+ # CLI (e.g. `make backend`); a sentinel env var keeps it from running twice.
491+ # No-op in dev.
492+ if resolved_profile == "prod" :
493+ from langflow .cli .preflight import run_production_preflight
494+
495+ if not run_production_preflight (get_settings_service (), verbose = verbose ):
496+ raise typer .Exit (code = 1 )
497+
473498 # Step 2: Starting Core Services
474499 app = None
475500 app_factory = None
0 commit comments