我正在尝试在同一个端口上创建一个包含多个应用程序的凤凰伞项目。使用我当前的配置,我收到此错误:
⧕ /m/i/d/p/e/portfolio on master * ⟩mix phoenix.server 13m 20s 412ms
==> rumbl
Compiling 17 files (.ex)
Generated rumbl app
[info] Running Rumbl.Endpoint with Cowboy using http://localhost:8080
[error] Failed to start Ranch listener Persona.Endpoint.HTTP in :ranch_tcp:listen([port: 8080]) for reason :eaddrinuse (address already in use)
[info] Application persona exited: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}
** (Mix) Could not start application persona: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}
我的伞形项目的详细信息是我目前有 3 个应用程序。1 个应用代理对其他 2 个应用的请求。代理应用程序是一个基本的插件应用程序。
# /apps/proxy/lib/proxy/plug.ex
...
def call(conn, _opts) do
cond do
conn.host =~ ~r{rumbl.} ->
Rumbl.Endpoint.call(conn, [])
true ->
Persona.Endpoint.call(conn, [])
end
end
...
角色应用
# /apps/persona/config/dev.exs
...
config :persona, Persona.Endpoint,
http: [port: 8080],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../", __DIR__)]]
...
Rumbl.app
# /apps/rumbl/config/dev.exs
config :rumbl, Rumbl.Endpoint,
http: [port: 8080],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../", __DIR__)]]
我的要求是因为我正在使用 nanabox.io 进行开发和部署,并且它要求在端口 8080 上接收所有 http/https。