[Elixir003] managing config through environment variables (environment Variables)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.