Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions reflex/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:

if not environment.ALEMBIC_CONFIG.get().exists():
console.warn(
"Database is not initialized, run [bold]reflex db init[/bold] first."
"Database is not initialized, run [bold]reflex db init[/bold] first.",
dedupe=True,
)
_ENGINE[url] = sqlalchemy.engine.create_engine(
url,
Expand Down Expand Up @@ -153,7 +154,8 @@ def get_async_engine(url: str | None) -> sqlalchemy.ext.asyncio.AsyncEngine:

if not environment.ALEMBIC_CONFIG.get().exists():
console.warn(
"Database is not initialized, run [bold]reflex db init[/bold] first."
"Database is not initialized, run [bold]reflex db init[/bold] first.",
dedupe=True,
)
_ASYNC_ENGINE[url] = sqlalchemy.ext.asyncio.create_async_engine(
url,
Expand Down Expand Up @@ -316,8 +318,12 @@ def get_db_status() -> dict[str, bool]:
engine = get_engine()
with engine.connect() as connection:
connection.execute(sqlalchemy.text("SELECT 1"))
except sqlalchemy.exc.OperationalError:
except Exception as exc:
status = False
console.error(
f"Database health check failed: {exc} (subsequent errors will not be logged)",
dedupe=True,
)

return {"db": status}

Expand Down
11 changes: 7 additions & 4 deletions reflex/utils/prerequisites.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ async def get_redis_status() -> dict[str, bool | None]:
Returns:
The status of the Redis connection.
"""
from redis.exceptions import RedisError

try:
status = True
redis_client = get_redis()
Expand All @@ -442,8 +440,12 @@ async def get_redis_status() -> dict[str, bool | None]:
await ping_command
else:
status = None
except RedisError:
except Exception as exc:
status = False
console.error(
f"Redis health check failed: {exc} (subsequent errors will not be logged)",
dedupe=True,
)

return {"redis": status}

Expand Down Expand Up @@ -645,7 +647,8 @@ def check_db_initialized() -> bool:
and not environment.ALEMBIC_CONFIG.get().exists()
):
console.error(
"Database is not initialized. Run [bold]reflex db init[/bold] first."
"Database is not initialized. Run [bold]reflex db init[/bold] first.",
dedupe=True,
)
return False
return True
Expand Down
Loading