We’re using elixir 1.11 and deploying with docker so I have “server: true” in my endpoint configuration within config/runtime.exs. The problem is that starting up a console also starts the web app so if I have a server running, there is a port collision and the console doesn’t start. Is there some simple way around this that I’m missing?
When using releases use the remote_console option instead of the console option. This uses a remote console running inside the existing BEAM node instead of spawning a second one. This is also nice because it allows you to investigate the web server runtime if you need to, for example, see what processes are using up too much memory.
Thanks, that will fix my problem plus be a very nice addition to my toolbox! I think there is still an issue using runtime.exs in that you don’t know whether you’re in releases or mix mode but I can resolve that by moving the
server: true part of the configuration to prod.exs or surrounding it with a
if config_env() == :prod. There will still be a problem if someone wants to use releases in dev mode. I wonder if there might be something like the following that I could add to runtime.exs to resolve this?
if config_releases?() do config :my_app, MyAppWeb.Endpoint, server: true end
You can check for the release specific environment variables, such as
RELEASE_NODE, for example:
if System.get_env("RELEASE_NODE") do ... end