0
votes

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?

1
Running with iex -S mix phx.server show any error?David Magalhães

1 Answers

0
votes

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.