混合版本不适用于 Phoenix 实时查看演示应用程序

问题描述

背景

我正在玩弄 Phoenix LiveView,我已经使用 mix phx.new demo --live --no-ecto 设置了一个应用程序。

我的主要目标是创建此应用的一个版本,以便我可以根据需要调整它,但我遇到了问题。

问题

为了为我的演示应用创建一个版本,我遵循了 Deploying with releases 教程并更改了所有必要的文件

将以下内容添加到我的 mix.exs

  def project do
    [
      app: :demo,version: "0.1.0",elixir: "~> 1.7",elixirc_paths: elixirc_paths(Mix.env()),compilers: [:phoenix,:gettext] ++ Mix.compilers(),start_permanent: Mix.env() == :prod,aliases: aliases(),deps: deps(),releases: releases()
    ]
  end

  defp releases,do:
    [
      demo: [
        applications: [demo: :permanent]
      ]
    ]

并正确更改运行时配置中列出的文件

https://hexdocs.pm/phoenix/releases.html#runtime-configuration

但是,当我执行 _build/prod/rel/my_app/bin/demo start 时什么也没有发生。如果我执行 _build/prod/rel/my_app/bin/demo start_iex,我会得到以下输出

$ _build/prod/rel/demo/bin/demo start_iex
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

*** ERROR: Shell process terminated! (^G to start new job) ***
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Interactive Elixir (1.11.3) - press Ctrl+C to exit (type h() ENTER for help)
iex>

这让我相信有什么东西坠毁了。

当我访问 localhost:4000 时,它说服务器已关闭

问题

我做错了什么?

解决方法

答案

问题出在我的原始配置文件 config/config.exs 中。

我有

# Configures the endpoint
config :demo,DemoWeb.Endpoint,url: [host: "localhost"],secret_key_base: "MY_SECRET_KEY",render_errors: [view: DemoWeb.ErrorView,accepts: ~w(html json),layout: false],pubsub_server: Demo.PubSub,live_view: [signing_salt: "yRZCwQIF"]

在这里我错过了这一行:

# Configures the endpoint
config :demo,server: true

所以完整的配置应该是:

# Configures the endpoint
config :demo,live_view: [signing_salt: "yRZCwQIF"],server: true

有了这个配置,服务器现在可以工作了。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...