Postgresql Phoenix Elixir蒸馏厂未使用正确的数据库连接
我正试图用Distillery构建一个Phoenix应用程序,但是当我尝试启动编译后的应用程序时,我不断得到一个错误,即无法对数据库进行优化Postgresql Phoenix Elixir蒸馏厂未使用正确的数据库连接,postgresql,elixir,phoenix-framework,distillery,Postgresql,Elixir,Phoenix Framework,Distillery,我正试图用Distillery构建一个Phoenix应用程序,但是当我尝试启动编译后的应用程序时,我不断得到一个错误,即无法对数据库进行优化 17:44:50.925 [error] GenServer #PID<0.1276.0> terminating ** (KeyError) key :database not found in: [hostname: "localhost", username: "martinffx", types: Ecto.Adapters.Postg
17:44:50.925 [error] GenServer #PID<0.1276.0> terminating
** (KeyError) key :database not found in: [hostname: "localhost", username: "martinffx", types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Glitchr.Repo.Pool, otp_app: :glitchr, repo: Glitchr.Repo, adapter: Ecto.Adapters.Postgres, pool_size: 10, ssl: true, pool_timeout: 5000, timeout: 15000, adapter: Ecto.Adapters.Postgres, pool_size: 10, ssl: true, pool: DBConnection.Poolboy]
(elixir) lib/keyword.ex:343: 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
Last message: nil
其中我的数据库url是数据库\u url=postgres://glitchr:password@db:5433/glitchr
为什么呢?我如何调试我不正确的地方?我认为
系统.get_env
在配置中不起作用,因为它们将在编译时而不是运行时进行计算。瞧,谢谢你,狗伯特!总是帮助我的长生不老药之旅!将System.get_env
替换为{:System”“}
有效。我在部署到Heroku时遇到了相同的错误,但使用{:System,“DATABASE_URL”}无法解决此问题
等。更改此选项真的解决了问题吗?我认为System.get_env
不会在配置中工作,因为它们将在编译时而不是运行时进行评估。瞧,谢谢你,狗伯特!总是帮助我的长生不老药之旅!将System.get_env
替换为{:System”“}
可以工作。我在部署到Heroku时遇到了相同的错误,但使用{:System,“DATABASE_URL”}
等方法无法解决。更改为该方法真的解决了问题吗?
config :glitchr, Glitchr.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "localhost", port: {:system, "PORT"}],
cache_static_manifest: "priv/static/manifest.json",
server: true,
root: ".",
version: Mix.Project.config[:version],
secret_key_base: System.get_env("SECRET_KEY_BASE")
config :glitchr, Glitchr.Repo,
adapter: Ecto.Adapters.Postgres,
url: System.get_env("DATABASE_URL"),
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
ssl: true