In the config of elixir, we sometimes use some configuration items that we don't want to expose, and the usual practice is like Phoenix
#config/ prod.exsuse mix.config ... # Finally Import the config / prod.secret.exs# which should be versioned separately." Prod.secret.exs "
Above, we can put items that should not be exposed (such as database Passwd,auth_token ... All of these important items are written in the Prod.secret.exs (link visible example)
Let's put prod.secret.exs this file out of the project's version management, and run a git repository separately.
but sometimes we don't want to do that again, and there's a way (and it feels better than the method above)
is to write all the items that should be written in Prod.sesret.exs into the environment variables of the system.
#config/ prod.exsuse Mix.config....config:application_name, Applicationname.repo, adapter: Ecto.Adapters.MySQL, username:System.get_env ("Prod_repo_username"), password:System.get_env ( "Prod_repo_password"), database:System.get_env ("Prod_repo_database"), hostname: System.get_env ("Prod_repo_hostname") ...
Only need to be on the server
#prod. env
Export prod_repo_username= ' USERNAME 'export prod_repo_password= ' loveyou 'export prod_ Repo_database= ' DATABASE 'export prod_repo_hostname= ' 11.11.11.11 '
Only need to first
>Source prod.env>iex-s Mix
This allows the configuration of the elixir to be managed through environment variables.
What benchmarks do on my developer
[Elixir003] managing config through environment variables (environment Variables)