fix: add error handling to unsupervised Task.start calls in application.ex

- Grid cache warm-up and ML model load now wrapped in try/rescue
  so silent failures are logged instead of lost
This commit is contained in:
Graham McIntire 2026-06-01 15:40:38 -05:00
parent bca2174f71
commit e8b143813e
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -97,7 +97,15 @@ defmodule Microwaveprop.Application do
# master: when executed here the loaded rows live on the app master's
# heap and never GC (it's idle after boot), pinning ~800 MiB for the
# lifetime of the pod.
{:ok, _pid} = Task.start(fn -> Microwaveprop.Weather.warm_grid_cache_from_latest_profile() end)
{:ok, _pid} =
Task.start(fn ->
try do
Microwaveprop.Weather.warm_grid_cache_from_latest_profile()
rescue
e ->
Logger.error("Application: grid cache warm failed: #{Exception.format(:error, e, __STACKTRACE__)}")
end
end)
# One-shot backfill: enqueue a QRZ-lookup job for every user with a
# missing home QTH. Idempotent — the worker no-ops if home_grid is
@ -118,7 +126,12 @@ defmodule Microwaveprop.Application do
if Application.get_env(:microwaveprop, :load_ml_model, false) do
{:ok, _pid} =
Task.start(fn ->
Microwaveprop.Propagation.load_ml_model()
try do
Microwaveprop.Propagation.load_ml_model()
rescue
e ->
Logger.error("Application: ML model load failed: #{Exception.format(:error, e, __STACKTRACE__)}")
end
end)
end