Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

elixir - Mix release not working on Phoenix live view demo app

Background

I am toying with Phoenix LiveView and I have setup an app with mix phx.new demo --live --no-ecto.

My primary objective is to create a release of this app, so then I can adapt it to what I need, but I am having trouble.

Problem

In order to create a release for my demo app I followed the Deploying with releases tutorial and changed all the necessary files.

Added the following to my 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]
      ]
    ]

And changed the files listed in Runtime Configurations properly as well:

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

However, when I execute _build/prod/rel/my_app/bin/demo start nothing happens. If I execute _build/prod/rel/my_app/bin/demo start_iex I get the following output:

$ _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>

Which leads me to believe something crashed.

When I visit localhost:4000 it says the server is down.

Question

What am I doing wrong?

question from:https://stackoverflow.com/questions/65830776/mix-release-not-working-on-phoenix-live-view-demo-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Answer

The issue was in my original configuration file config/config.exs.

I had

# 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"]

Here I was missing the line:

# Configures the endpoint
config :demo, DemoWeb.Endpoint,
  server: true

So the full configuration should be:

# 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"],
  server: true

With this configuration now the server works.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...