I want to run 2 phoenix applications on the same server. The first one is working great on the default 4000 port. I want the second app to run on port 4001. I thought just setting up a custom env var would work but have had no success. I can manually start the 2nd app by passing in the port, but if I try to use edeliver it always uses the default port of 4000.
Oh, I forgot. Phoenix 1.3 moved it to :on_init. Go to lib/web/endpoint.ex and edit the load_from_system_env/1 function at the bottom to
def load_from_system_env(config) do
port = System.get_env("PORTAPI") || raise "expected the PORTAPI environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
end
@cevado and @net you guys rock. First off for taking the time to help me out, and being patient with me. I’m going to write a blog post eventually about all of this deployment stuff to give back to the community. It has taken me a ton of time to figure it out being a n00b. I’ve now got working ansible playbooks that setup both build and production servers. And also have circleci integrated for CI.
To be clear for future readers, there’s no reason why {:system, “PORT”} shouldn’t work with Distillery.
For sure, I totally get it wrong… I was reading about it to be sure… the change from exrm and distillery was only RELX_REPLACE_OS_VARS that started to be used as a REPLACE_OS_VARS.
exrm used relx and this "${env_var}" pattern is a relx thing.
distillery stoped using relx and kept the old way but now enforces the tuple pattern created by phoenix(using exrm {:system, "env_var"} would only work with phoenix configurations).