Set Kafka envs on runtime instead of compile time
This commit is contained in:
@@ -49,9 +49,3 @@ config :logger, level: :info
|
||||
#
|
||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||
|
||||
config :kafka_ex,
|
||||
brokers: [
|
||||
{System.get_env("KAFKA_BROKER_1_HOST"), System.get_env("KAFKA_BROKER_1_PORT")},
|
||||
{System.get_env("KAFKA_BROKER_2_HOST"), System.get_env("KAFKA_BROKER_2_PORT")},
|
||||
{System.get_env("KAFKA_BROKER_3_HOST"), System.get_env("KAFKA_BROKER_3_PORT")}
|
||||
]
|
||||
|
||||
@@ -13,19 +13,7 @@ if System.get_env("PHX_SERVER") && System.get_env("RELEASE_NAME") do
|
||||
end
|
||||
|
||||
if config_env() == :prod do
|
||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
||||
# A default value is used in config/dev.exs and config/test.exs but you
|
||||
# want to use a different value for prod and you most likely don't want
|
||||
# to check this value into version control, so we use an environment
|
||||
# variable instead.
|
||||
secret_key_base =
|
||||
System.get_env("SECRET_KEY_BASE") ||
|
||||
raise """
|
||||
environment variable SECRET_KEY_BASE is missing.
|
||||
You can generate one by calling: mix phx.gen.secret
|
||||
"""
|
||||
|
||||
host = System.get_env("PHX_HOST") || "example.com"
|
||||
host = System.get_env("PHX_HOST") || "localhost"
|
||||
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||
|
||||
config :kafkaex_lag_exporter, KafkaexLagExporterWeb.Endpoint,
|
||||
@@ -37,8 +25,7 @@ if config_env() == :prod do
|
||||
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0},
|
||||
port: port
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
]
|
||||
|
||||
# ## Using releases
|
||||
#
|
||||
@@ -50,3 +37,14 @@ if config_env() == :prod do
|
||||
# Then you can assemble a release by calling `mix release`.
|
||||
# See `mix help release` for more information.
|
||||
end
|
||||
|
||||
{port, _} = System.fetch_env!("KAFKA_BROKER_PORT")
|
||||
|> Integer.parse
|
||||
|
||||
config :kafka_ex,
|
||||
brokers: [
|
||||
{System.fetch_env!("KAFKA_BROKER1_HOST"), port},
|
||||
{System.fetch_env!("KAFKA_BROKER2_HOST"), port},
|
||||
{System.fetch_env!("KAFKA_BROKER3_HOST"), port},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user