debug: add detailed logging to health check endpoint
Added logging to identify which component is failing health checks: - Log database and Redis status on each health check - Log Redis errors with full error details - This will help diagnose the production 503 errors
This commit is contained in:
parent
6c1f344b5e
commit
a84fc07e42
1 changed files with 14 additions and 2 deletions
|
|
@ -7,9 +7,14 @@ defmodule ToweropsWeb.HealthController do
|
|||
alias Towerops.Repo
|
||||
|
||||
def index(conn, _params) do
|
||||
require Logger
|
||||
|
||||
db_status = check_database()
|
||||
redis_status = check_redis()
|
||||
|
||||
# Log health check results for debugging
|
||||
Logger.debug("Health check: db=#{inspect(db_status)}, redis=#{inspect(redis_status)}")
|
||||
|
||||
all_healthy = db_status == :ok and redis_status in [:ok, :not_configured]
|
||||
|
||||
if all_healthy do
|
||||
|
|
@ -46,16 +51,23 @@ defmodule ToweropsWeb.HealthController do
|
|||
end
|
||||
|
||||
defp check_redis do
|
||||
require Logger
|
||||
|
||||
redis_config = Application.get_env(:towerops, :redis, [])
|
||||
|
||||
if Keyword.has_key?(redis_config, :host) do
|
||||
# Redis is configured, check connectivity with short timeout for health check
|
||||
case Towerops.RedisHealthCheck.check_health(redis_config, 2_000) do
|
||||
:ok -> :ok
|
||||
{:error, _} -> :error
|
||||
:ok ->
|
||||
:ok
|
||||
|
||||
{:error, reason} ->
|
||||
Logger.error("Redis health check failed: #{inspect(reason)}")
|
||||
:error
|
||||
end
|
||||
else
|
||||
# Redis not configured (e.g., in development without Redis)
|
||||
Logger.debug("Redis not configured")
|
||||
:not_configured
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue