File tree 1 file changed +14
-2
lines changed
lib/plausible_web/controllers/api
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
defmodule PlausibleWeb.Api.SystemController do
2
2
use PlausibleWeb , :controller
3
+ require Logger
3
4
4
5
def info ( conn , _params ) do
5
6
build =
@@ -20,9 +21,20 @@ defmodule PlausibleWeb.Api.SystemController do
20
21
json ( conn , % { ok: true } )
21
22
end
22
23
24
+ @ task_timeout 15_000
23
25
def readiness ( conn , _params ) do
26
+ postgres_health_task =
27
+ Task . async ( fn ->
28
+ Ecto.Adapters.SQL . query ( Plausible.Repo , "SELECT 1" , [ ] )
29
+ end )
30
+
31
+ clickhouse_health_task =
32
+ Task . async ( fn ->
33
+ Ecto.Adapters.SQL . query ( Plausible.ClickhouseRepo , "SELECT 1" , [ ] )
34
+ end )
35
+
24
36
postgres_health =
25
- case Ecto.Adapters.SQL . query ( Plausible.Repo , "SELECT 1" , [ ] ) do
37
+ case Task . await ( postgres_health_task , @ task_timeout ) do
26
38
{ :ok , _ } ->
27
39
"ok"
28
40
@@ -32,7 +44,7 @@ defmodule PlausibleWeb.Api.SystemController do
32
44
end
33
45
34
46
clickhouse_health =
35
- case Ecto.Adapters.SQL . query ( Plausible.ClickhouseRepo , "SELECT 1" , [ ] ) do
47
+ case Task . await ( clickhouse_health_task , @ task_timeout ) do
36
48
{ :ok , _ } ->
37
49
"ok"
38
50
You can’t perform that action at this time.
0 commit comments