I tried adding a child to the supervision tree which boiled down to this:
defmodule MyApp.Application do
alias MyApp.Contexts.MyContext
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
supervisor(MyApp.Repo, []),
worker(Task, [&MyContext.warm_up_cache/0], restart: :temporary)
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end
That works, but blows up with errors when the database is down or being provisioned (which is obvious in retrospect). Instead, I think what I want in this case is a blocking task: i.e. wait to start the rest of the app until this one thing is complete.
Does someone have a good example of how to do something like this? My example here is warming up the cache.
Thanks for any guidance!


















