I have some workers (children) in Application.start
. They shouldn't be started if phoenix app running from task other than mix phx.server
(for example with mix ecto.reset
).
So, how to know in Application.start
that it is mix phx.server
running the code?
You can use Phoenix.Endpoint.server?(otp_app, endpoint)
to check if an endpoint is running its server under the given app. Here are the docs: https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#server?/2