You want the database to be available (I assume Repo) but the app should not be accessible from the outside? Or when you say wait to start the rest of the app, what do you want to prevent happening? Doing a cache warmup seems like something that can run async, unless the cache is the only data source you have.
Maybe if you specify what parts of the app you want to start before your cache warmup and which parts that should wait until after.
eg the Statix library is started by calling connect in start. So with your code example
defmodule MyApp.Application do
alias MyApp.Contexts.MyContext
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
:ok = MyStatixModule.connect()
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 means connect is called before the app starts. But note that in this case, the Repo is not needed for that and not started yet.






















