mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
fix: make migration failure non-fatal by default, add --require_db_migration flag
By default the proxy now warns and continues when database migration fails. Pass --require_db_migration (or set REQUIRE_DB_MIGRATION=true) to restore the previous behavior of exiting with an error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ae1c7854e6
commit
304f0d9ad1
1 changed files with 19 additions and 5 deletions
|
|
@ -556,6 +556,13 @@ class ProxyInitializationHelpers:
|
|||
help="Restart worker after this many requests (uvicorn: limit_max_requests, gunicorn: max_requests)",
|
||||
envvar="MAX_REQUESTS_BEFORE_RESTART",
|
||||
)
|
||||
@click.option(
|
||||
"--require_db_migration",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Exit with error if database migration fails. By default the proxy will warn and continue.",
|
||||
envvar="REQUIRE_DB_MIGRATION",
|
||||
)
|
||||
def run_server( # noqa: PLR0915
|
||||
host,
|
||||
port,
|
||||
|
|
@ -595,6 +602,7 @@ def run_server( # noqa: PLR0915
|
|||
skip_server_startup,
|
||||
keepalive_timeout,
|
||||
max_requests_before_restart,
|
||||
require_db_migration: bool,
|
||||
):
|
||||
args = locals()
|
||||
if local:
|
||||
|
|
@ -857,11 +865,17 @@ def run_server( # noqa: PLR0915
|
|||
if not PrismaManager.setup_database(
|
||||
use_migrate=not use_prisma_db_push
|
||||
):
|
||||
print( # noqa
|
||||
"\033[1;31mLiteLLM Proxy: Database setup failed after multiple retries. "
|
||||
"The proxy cannot start safely. Please check your database connection and migration status.\033[0m"
|
||||
)
|
||||
sys.exit(1)
|
||||
if require_db_migration:
|
||||
print( # noqa
|
||||
"\033[1;31mLiteLLM Proxy: Database setup failed after multiple retries. "
|
||||
"The proxy cannot start safely. Please check your database connection and migration status.\033[0m"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print( # noqa
|
||||
"\033[1;33mLiteLLM Proxy: Database migration failed but continuing startup. "
|
||||
"Use --require_db_migration to exit on migration failure.\033[0m"
|
||||
)
|
||||
else:
|
||||
print( # noqa
|
||||
f"Unable to connect to DB. DATABASE_URL found in environment, but prisma package not found." # noqa
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue