ijt*_*ijt 4 elixir phoenix-framework
在config/test.exs,我有以下几行:
config :youli, Youli.Endpoint,
http: [port: System.get_env("PORT") || 4001
Run Code Online (Sandbox Code Playgroud)
当我运行时mix release,解压缩版本,并使用PORT = 4242运行应用程序,它会在端口4001上运行.稍微踩了一下,我发现它是硬编码的releases/0.0.3/sys.config.
如何使用环境中的端口集运行我的版本?
ijt*_*ijt 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"}]
Run Code Online (Sandbox Code Playgroud)
有关此文档的文档lib/phoenix/endpoint.ex位于Phoenix源文件中.