wemgl

wemgl

Phoenix Umbrella Prod Release Doesn't Start

Hey everyone, I’m hoping you’ll be able to help me with an Elixir Releases issue. I searched the forums for a similar
post, but the one I found, doesn’t apply as the
issue there was a typo.

So, I’m building and following the instructions from here. I’m able to go through
all the steps it outlines without any issues, but since my app is an umbrella application I had to make
a few modifications. Here’s the make target I made to consolidate the steps:

.PHONY: release-build
## release-build: builds a local release version of the app
release-build:
	mix deps.get --only prod && \
	MIX_ENV=prod mix compile && \
	npm install --prefix apps/my_app_web/assets && \
	npm run deploy --prefix apps/my_app_web/assets && \
	mix phx.digest && \
	MIX_ENV=prod mix release --overwrite

My mix.exs file with the release configuration of the release looks like this (with the actual app’s name removed):

  defp releases do
    [
      my_app_web: [
        include_executables_for: [:unix],
        applications: [
          runtime_tools: :permanent
        ]
      ]
    ]
  end

The release is built and run on macOS Catalina 10.15.7. Now, the build works and the _build/prod directory gets
generated without any issues, but when I try starting it with _build/prod/rel/my_app_web/bin/my_app_web start the application
seems like it’s running, but I can’t navigate to the landing page in my browser.

Here’s how I have everything configured:
Elixir is version:

Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.11.1 (compiled with Erlang/OTP 23)

and Phoenix version is 1.5.4. I’m using Runtime Configuration which seems to be set properly when I start-up iex:

# config/runtime.exs file
import Config

if config_env() == :prod do
  config :my_app_web,
         MyAppWeb.Endpoint,
         server: true,
         http: [
           port: String.to_integer(System.fetch_env!("MA_PORT")),
           transport_options: [
             socket_opts: [:inet6]
           ]
         ],
         secret_key_base: System.fetch_env!("MA_SECRET_KEY_BASE"),
         basic_auth: [
           username: System.fetch_env!("MA_BASIC_AUTH_USERNAME"),
           password: System.fetch_env!("MA_BASIC_AUTH_PASSWORD")
         ]

  config :my_app,
         MyApp.Repo,
         url: System.fetch_env!("MA_DATABASE_URL")
end
# :my_app_web config
[
  {MyAppWeb.Endpoint,
   [
     render_errors: [
       view: MyAppWeb.ErrorView,
       accepts: ["html", "json"],
       layout: false
     ],
     pubsub_server: MyApp.PubSub,
     live_view: [signing_salt: "signing_salt"],
     url: [host: "MyApp.com", port: 80],
     cache_static_manifest: "priv/static/cache_manifest.json",
     server: true,
     http: [port: 8080, transport_options: [socket_opts: [:inet6]]],
     secret_key_base: "secret_key_base",
     basic_auth: [username: "admin", password: "admin"]
   ]}
]
# :my_app config
[
  {:generators, [context_app: false]},
  {MyApp.Repo,
   [url: "ecto://postgres:postgres@localhost/my_app_development"]},
  {:ecto_repos, [MyApp.Repo]}
]

What is interesting is that if I start the app with _build/prod/rel/my_app_web/bin/my_app_web start_iex and then
try to call a function on one of my modules, say MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads, then I get:

** (UndefinedFunctionError) function MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads/0 is undefined (module MyApp.Marketing.LifeCoachingLeads is not available)
    MyApp.Marketing.LifeCoachingLeads.list_life_coaching_leads()

Which makes me think my release isn’t finding the modules it needs to start up, but it’s not obvious to me why.
Any pointers in the right direction would be fantastic!

Marked As Solved

josevalim

josevalim

Creator of Elixir

That’s only the script name. Go to the end of the file and see if your apps are being started.

One thing to keep in mind though is that in an umbrella you have to explicitly include your umbrella children in the list of applications given to the release.

Also Liked

josevalim

josevalim

Creator of Elixir

Awesome job debugging things so far! Inside your release, you are going to find out a releases/VSN directory where VSN is the current version. Inside that directory, there is a start.script file with all steps the Erlang VM takes to boot the app. When you inspect this file, can you see your applications there?

Another way to debug is: try adding a IO.inspect :OMG to start/2 in your lib/my_app_web/application.ex and see if it is printed when you start the release.

Last Post!

wemgl

wemgl

Thanks @josevalim! That was the root of the issue. I took this portion of the docs too literally:

[
        include_executables_for: [:unix],
        applications: [runtime_tools: :permanent]
      ],

I mistook runtime_tools for a config option instead of being the name of the app to include in the release. Once I replaced it with my apps actual name it worked. I really appreciate the help!

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New

We're in Beta

About us Mission Statement