elixir - 酿酒厂版本的配置

标签 elixir phoenix-framework distillery

我走过https://hexdocs.pm/distillery/getting-started.html文档,但无法运行基本的 Phoenix 应用程序。这就是我所做的:

mix phoenix.new test_app --no-ecto
cd test_app

然后我更新 mix.exs 文件以包含酿酒厂部分:

[...]
defp deps do
  [{:phoenix, "~> 1.2.0-rc"},
   {:phoenix_pubsub, "~> 1.0.0-rc"},
   {:phoenix_html, "~> 2.5"},
   {:phoenix_live_reload, "~> 1.0", only: :dev},
   {:gettext, "~> 0.11"},
   {:cowboy, "~> 1.0"},
   {:distillery, "~> 0.9"}]
end
[...]

然后我运行以下命令:

mix deps.get
mix compile
mix release.init
export PORT=4000
./node_modules/brunch/bin/brunch b -p
MIX_ENV=prod mix do phoenix.digest, release --env=prod

结果是这样的:

05 Sep 17:16:02 - info: compiled 6 files into 2 files, copied 3 in 1.7 sec
Check your digested files at "priv/static"
==> Assembling release..
==> Building release test_app:0.0.1 using environment prod
==> Packaging release..
==> Release successfully built!
    You can run it in one of the following ways:
      Interactive: rel/test_app/bin/test_app console
      Foreground: rel/test_app/bin/test_app foreground
      Daemon: rel/test_app/bin/test_app start

根据我的理解,我应该能够使用以下命令启动 Phoenix 应用程序

rel/test_app/bin/test_app foreground

但是当我这样做时,我无法通过浏览器通过 URL http://localhost:4000

访问它

我是否设置错误或者误解了系统?我如何开始新版本?

最佳答案

Using Distillery With Phoenix 中所述页面,您需要更改 config/prod.exs 中的一些设置。将 TestApp.Endpoint 配置更改为:

config :test_app, TestApp.Endpoint,
  http: [port: {:system, "PORT"}],
  url: [host: "localhost", port: {:system, "PORT"}],
  cache_static_manifest: "priv/static/manifest.json",
  server: true,
  root: ".",
  version: Mix.Project.config[:version]

以下命令成功在之前导出的端口上启动 Phoenix:

rel/test_app/bin/test_app foreground 

关于elixir - 酿酒厂版本的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39333608/

相关文章:

elixir - 处理混合配置值

node.js - 尝试使用 axios 在 React/Phoenix 应用程序中进行 API 调用(使用 Brunch)

search - 在永久布局中创建搜索栏(app.html.eex)

elixir - 基于负载的Phoenix路由

elixir - Edeliver/Distillery 因 "bash: line 10: mix: command not found"错误而失败?

Elixir :invalid_child_spec for supervised process. 不知道为什么

elixir - Phoenix channel 的广播如何影响其他节点上的客户端?

elixir - Elixir 是否支持自省(introspection)以显示可用功能?