【问题标题】:Running iex mix phoenix.server on a different port does not work在不同的端口上运行 iex mix phoenix.server 不起作用
【发布时间】:2016-05-19 20:02:32
【问题描述】:

这看起来像一个错误,但我不确定。 谁能告诉我在不同的端口号上运行 iex 是否有效。它始终使用端口 4000。

PORT=4001 iex -S mix phoenix.server   

Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

[info] Running AppMessenger.Endpoint with Cowboy using http on port 4000
Interactive Elixir (1.2.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 19 May 19:53:40 - info: compiled 5 files into 2 files, copied 3 in 714ms

【问题讨论】:

    标签: elixir phoenix-framework


    【解决方案1】:

    默认情况下,config/dev.exs 有一个硬编码值 4000 用于 Phoenix 中的端口。如果您想使用来自dev 中的PORT 环境变量的值,请在config/dev.exs 中更改:

    http: [port: 4000]
    

    http: [port: {:system, "PORT"}]
    

    【讨论】:

    • 但现在必须添加:export PORT=4000 as default。
    • 不幸的是,我认为没有办法使用{:system, "PORT"} 方法指定回退:github.com/phoenixframework/phoenix/blob/…
    • 回退会很好。同时,这对我来说比默认的开发效果更好。
    猜你喜欢
    • 2017-10-10
    • 2018-01-14
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2016-03-17
    • 1970-01-01
    • 2020-06-07
    相关资源
    最近更新 更多