I have a Phoenix repository that other engineers clone when creating a new app.
I have the following in the prod.exs
config :foo, Foo.Repo,
adapter: Ecto.Adapters.Postgres,
url: {:system, "DATABASE_URL"},
pool_size: 1
The engineer normally deploys the Phoenix server to production before its database is set up. The engineer will set up the database within a few days, but in the meantime my problem is that this generates a huge volume of log messages which my logging system has trouble handling.
Here is the log message.
15:48:29.496 [error] GenServer #PID<0.20959.1> terminating
** (KeyError) key :database not found in: [hostname: "localhost", username: "foo", types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Foo.Repo.Pool, otp_app: :foo, repo: Foo.Repo, adapter: Ecto.Adapters.Postgres, pool_size: 1, pool_timeout: 5000, timeout: 15000, adapter: Ecto.Adapters.Postgres, url: {:system, "DATABASE_URL"}, pool_size: 1, pool: DBConnection.Poolboy]
(elixir) lib/keyword.ex:333: Keyword.fetch!/2
(postgrex) lib/postgrex/protocol.ex:76: Postgrex.Protocol.connect/1
(db_connection) lib/db_connection/connection.ex:134: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
15:48:29.496 [error] GenServer #PID<0.20960.1> terminating
** (KeyError) key :database not found in: [hostname: "localhost", username: "foo", types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Foo.Repo.Pool, otp_app: :foo, repo: Foo.Repo, adapter: Ecto.Adapters.Postgres, pool_size: 1, pool_timeout: 5000, timeout: 15000, adapter: Ecto.Adapters.Postgres, url: {:system, "DATABASE_URL"}, pool_size: 1, pool: DBConnection.Poolboy]
(elixir) lib/keyword.ex:333: Keyword.fetch!/2
(postgrex) lib/postgrex/protocol.ex:76: Postgrex.Protocol.connect/1
(db_connection) lib/db_connection/connection.ex:134: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
15:48:29.497 [error] GenServer #PID<0.20961.1> terminating
I know how to fix the error, but it is the engineer's responsibility to eventually set the DATABASE_URL
environment variable. I can only modify the Phoenix app template repository that the engineer clones at the start.
Is there some way to modify prod.exs
so that an app without a DATABASE_URL
set doesn't generate tons of logs?