In config/test.exs
, I have the following lines:
config :youli, Youli.Endpoint,
http: [port: System.get_env("PORT") || 4001
When I run mix release
, untar the release, and run the app with PORT=4242, it runs on port 4001 instead. Grepping a bit, I found that it's hard-coded that way in releases/0.0.3/sys.config
.
How can I get my release to run with the port set from the environment?
Instead of System.get_env("PORT")
, use {: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"}]
The documentation for this is in lib/phoenix/endpoint.ex
in the Phoenix source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With