Mix run vs mix phx.server - is there a difference?

Is there any difference between mix run and mix phx.server in a phoenix project?

1 Like

mix phx.server also sets the configuration flag to actually start HTTP as by default Phoenix starts without HTTP listeners (which is behaviour of mix run).

4 Likes

Let’s find it out!

The phx.server doc gives the link to the source code

    Application.put_env(:phoenix, :serve_endpoints, true, persistent: true)

You can search serve_endpoints internal config option, which is used at the supervisor

  def server?(conf) when is_list(conf) do
    Keyword.get(conf, :server, Application.get_env(:phoenix, :serve_endpoints, false))
  end

So it loads :server config, or fall backs to serve_endpoints option! You can see :server config is set at config/test.exs and config/runtime.exs.

Another option set by phx.server is --no-halt to mix run.

So… mix phx.server is equivalent to PHX_SERVER=1 mix run --no-halt basically.

2 Likes