I've been working with Phoenix for a while and I always used it with mix, even in produciton (Heroku), however this time I'm using it inside an umbrella app with distillery.
So I wanted to start the application as a whole, and I was issuing $ mix run --no-halt command to run all the applications inside umbrella, but with that the Phoenix endpoint doesn't start listen on the configured port, so as the build generated by distillery, only with $ mix phx.server which starts all apps too, but I don't think this command is appropriate to run the umbrella app, IMHO.
Diving into Phoenix's source code, I found the phx.server mix task setting up a configuration just before running run mix's task, which made me think if this configuration shouldn't be set by default in config/config.exs (or even in some env related config file), or even if this should be a configuration at all, since when I start an application I think I'd like to have the endpoint listening to requests (I couldn't come up with a scenario in which this shouldn't happen). I'm saying that because to have my Phoenix app running with distillery I had to take that configuration to the app's config (in order to have :phoenix, serve_endpoints: true).
I'm not saying that we should remove the $ mix phx.server command, which is great for standalone Phoenix applications, but I think we should also have $ mix run putting the application up and running.
Be able to run an umbrella app and have all Phoenix endpoints running only with $ mix run [--no-halt] command.
Phoenix's endpoints only start when executing $ mix phx.server command.
I'm not sure should I open this as an issue since this is not a bug report, neither a feature request, neither a doubt on "how to" to have it on any other place.
Thank you!
since when I start an application I think I'd like to have the endpoint listening to requests (I couldn't come up with a scenario in which this shouldn't happen)
Here's a few scenarios when starting the endpoint on application start by default might be undesirable:
iex -S mix session because the 2nd run would try to bind to an already taken http port. Same goes for running mix run script.exs or running Mix tasks. Imagine you have a Mix task that performs some ops work and requires app start (e.g. needs repo, cache etc to be started), you'd now have to explicitly _disable_ endpoint in that taskAs you pointed out, it's relatively easy to start the endpoint by setting serve_endpoints: true, so you could configure your app in dev to do just that.
Wojtek answered this perfectly. Thanks!
Got it! Thank you guys!
Most helpful comment
Here's a few scenarios when starting the endpoint on application start by default might be undesirable:
iex -S mixsession because the 2nd run would try to bind to an already taken http port. Same goes for runningmix run script.exsor running Mix tasks. Imagine you have a Mix task that performs some ops work and requires app start (e.g. needs repo, cache etc to be started), you'd now have to explicitly _disable_ endpoint in that taskAs you pointed out, it's relatively easy to start the endpoint by setting
serve_endpoints: true, so you could configure your app indevto do just that.