I'm trying to deploy my Elixir/Phoenix Application with exrm. This works fine except that I'm not able to read some config entries defined in config/config.exs
when starting the app via the release "binary".
My config/config.exs
locks like this (I removed some lines for clarity):
use Mix.Config
config :phoenix, RestProxy.Router,
port: System.get_env("PORT")
# ...
config :logger,
backends: [:console, Logjam.LoggerBackend]
# ...
config :logjam, :forwarder,
app_name: "profileproxy",
enabled: false
I also generated the conform
config via
mix conform.new
mix conform.configure
and left them unchanged.
If I build it via mix release
, start it with ./rel/my_app/bin/my_app start
and connect with the remote console, I can read some config entries, but not the logjam one:
> ./rel/rest_proxy/bin/rest_proxy remote_console
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernelpoll:false] [dtrace]
Interactive Elixir (1.0.0) - press Ctrl+C to exit (type h() ENTER for help)
iex([email protected])1> Application.get_env(:logger, :backends)
[:console, Logjam.LoggerBackend]
iex([email protected])2> Application.get_env(:logjam, :forwarder)
nil
The generated sys.config
in rel/my_app/releases/0.0.1/
looks like this:
[{sasl,[{errlog_type,error}]},
{phoenix,
[{'Elixir',
[{'MyApp',
[{'Router',
[{cookies,true},
{debug_errors,true},
{host,<<"localhost">>},
{port,4000},
{session_key,<<"_rest_proxy_key">>},
{session_secret,<<"snip">>},
{ssl,false}]}]}]},
{'Elixir.MyApp.Router',
[{port,nil},
{ssl,false},
{host,<<"example.com">>},
{cookies,true},
{session_key,<<"_rest_proxy_key">>},
{session_secret,<<"snip">>}]},
{code_reloader,[{enabled,true}]}]},
{logger,
[{backends,[console,'Elixir.Logjam.LoggerBackend']},
{format,<<"$time $metadata[$level] $message">>},
{handle_otp_reports,true},
{handle_sasl_reports,true},
{metadata,[request_id]}]},
{logjam,[{forwarder,[{app_name,<<"profileproxy">>},{enabled,false}]}]}].
I'm using elixir 1.0.0, phoenix 0.4.1 and exrm 0.14.9.
Any ideas/hints why I can't read the config?
I would assume this is because there is no application called
logjam
loaded in your release. To quote the Erlang docs for:application.get_env
:In your case, you see nil because given an empty keyword list,
Application.get_env
is unable to find a key by the name of:forwarder
, and so returns nil by default.