4

config/test.exs中,我有以下几行:

config :youli, Youli.Endpoint,
  http: [port: System.get_env("PORT") || 4001

当我运行时mix release,解压发行版并使用 PORT=4242 运行应用程序,它会在端口 4001 上运行。摸索了一下,我发现它在releases/0.0.3/sys.config.

如何让我的版本使用环境中的端口集运行?

4

2 回答 2

10

而不是System.get_env("PORT"),使用{:system, "PORT"}

$ git diff
diff --git a/phoenix/config/test.exs b/phoenix/config/test.exs
index 10cea91..617f34c 100644
--- a/phoenix/config/test.exs
+++ b/phoenix/config/test.exs
@@ -1,7 +1,7 @@
 use Mix.Config

  config :youli, Youli.Endpoint,
  -  http: [port: System.get_env("PORT") || 4001]
  +  http: [port: {:system, "PORT"}]

相关文档lib/phoenix/endpoint.ex位于 Phoenix 源代码中。

于 2015-03-12T06:05:24.847 回答
0

您可以使用{:system, "PORT"}System.get_env("PORT")

于 2015-08-24T15:32:48.707 回答