Skip to content

Instantly share code, notes, and snippets.

@AndrewDryga
Last active February 20, 2018 22:58
Show Gist options
  • Save AndrewDryga/76a8ad81b987309910430858e4d5870b to your computer and use it in GitHub Desktop.
Save AndrewDryga/76a8ad81b987309910430858e4d5870b to your computer and use it in GitHub Desktop.
Adding runtime config via Application.put_env/2 in Application start/2 callback
defmodule Sample.Application do
use Application
# ...
def start(_type, _args) do
import Supervisor.Spec
# ...
# Update application environment from system environment variable when application starts
Application.put_env(:sample_app, :configurable_env_var, System.get_env("CONFIGURABLE_ENV_VAR"))
# ...
Supervisor.start_link(children, opts)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment