New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need process for dynamically setting database port/host. #587

Closed
noizu opened this Issue May 8, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@noizu

noizu commented May 8, 2015

I run elixir within a docker instance and need the ability to set the database port/host at runtime from :os.environment variables.

The ability to set credentials via environment variables is also a common requirement for build systems where database details may not be known in advance. Is there already the ability to do this with the current code base. I've glanced things over for a bit but am fairly new to elixir/erlang and didn't spot an instance of this being done, nor do I know what the standard idiom would be to do so if the system follows some standard idiom that passes values in via start link settings etc.

If ability is available let me know the rough steps and I'll fork and update your docs for you with details. If not I'll go in and implement the capability for you.

Much thanks in advance. This library is a great resource either way ^_^.

  • Noizu
@josevalim

This comment has been minimized.

Member

josevalim commented May 8, 2015

It should be possible via the URL option or just reading environment variables in your config:

config :my_app, MyApp.Repo, port: System.get_env("PORT"), host: System.get_env("HOST")

And so on.

@josevalim josevalim closed this May 8, 2015

@noizu

This comment has been minimized.

noizu commented May 8, 2015

ack, that works. Thanks for the prompt reply that was killing me.

On Fri, May 8, 2015 at 7:57 PM, José Valim notifications@github.com wrote:

It should be possible via the URL option or just reading environment
variables in your config:

config :my_app, MyApp.Repo, port: System.get_env("PORT"), host: System.get_env("HOST")

And so on.


Reply to this email directly or view it on GitHub
#587 (comment).

@noizu

This comment has been minimized.

noizu commented May 8, 2015

Specifically:

port: System.get_env("MYSQL_PORT_3306_TCP_PORT") |> Integer.parse |> elem(0),
hostname: System.get_env("MYSQL_PORT_3306_TCP_ADDR") |> to_char_list

since matching fails on String Port.

note, allowing for matching on String Port followed by integer parse might save some users config headaches in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment