Skip to content

Commit

Permalink
Shut down the worker app if jobs are not processed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed Dec 24, 2024
1 parent 3e3bdcb commit 95f1b9a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/transport/lib/transport_web/plugs/worker_healthcheck.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do
if Oban attempted jobs recently.
"""
import Plug.Conn
require Logger

@app_start_waiting_delay {20, :minute}
@oban_max_delay_since_last_attempt {60, :minute}
Expand All @@ -36,6 +37,14 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do
Healthy state?: #{healthy_state?()}
""")
|> halt()

# NOTE: Clever Cloud monitoring will better pick stuff back up
# if the app is completely down.
if !healthy_state?() do
Logger.info "Hot-fix: shutting down!!!"
# "Carefully stops the Erlang runtime system."
System.stop()
end
else
conn
end
Expand Down

0 comments on commit 95f1b9a

Please sign in to comment.