在Elixir/Phoenix(0.10.0)中,如何根据版本中的端口环境变量设置端口?

在Elixir/Phoenix(0.10.0)中,如何根据版本中的端口环境变量设置端口?,elixir,phoenix-framework,Elixir,Phoenix Framework,在config/test.exs中,我有以下几行代码: config :youli, Youli.Endpoint, http: [port: System.get_env("PORT") || 4001 当我运行mix-release,卸载该版本,并运行端口为4242的应用程序时,它将在端口4001上运行。稍微放大一点,我发现在releases/0.0.3/sys.config中是这样硬编码的 如何让我的发行版使用环境中设置的端口运行?而不是系统。获取环境(“端口”),使用{:Syste

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

config :youli, Youli.Endpoint,
  http: [port: System.get_env("PORT") || 4001
当我运行
mix-release
,卸载该版本,并运行端口为4242的应用程序时,它将在端口4001上运行。稍微放大一点,我发现在
releases/0.0.3/sys.config
中是这样硬编码的


如何让我的发行版使用环境中设置的端口运行?

而不是
系统。获取环境(“端口”)
,使用
{:System,“port”}


这方面的文档位于phoenix源代码中的
lib/phoenix/endpoint.ex

您可以使用
{:system,“PORT”}
system.get_env(“PORT”)

凤凰城0.17.0和1.0.0对我来说都很有效。你说得对。Idk为什么我会有这个问题。我会检查原因并报告一个问题。
$ 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"}]