wemgl

wemgl

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!

Showing Posts 1 to 4

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.

wemgl

wemgl OP

I see it on the second line of the file:

%% coding: utf-8
{script,
    {"my_app_web","0.1.0"},
# bunch of other stuff

The file contains a lot of built-in Elixir modules Elixir.Calendar.ISO, Elixir.Map, and a lot of other modules, but none of the ones I’ve implemented.

I didn’t event think of this! I gave it a shot but I don’t see :OMG on startup either. I thought maybe I had setup the config/runtime.exs file wrong too, so I created a config/releases.exs file and put the configs in there and ran the app, but it still doesn’t start even though I see the proper start up message:

Check your digested files at "priv/static"
* assembling fit_whitt_it_web-0.1.0 on MIX_ENV=prod
* using config/releases.exs to configure the release at runtime
other stuff ...
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.

wemgl

wemgl OP

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!

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
psy-q
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews