Elixir exrm console works but application does not start automatically

373 views Asked by At

I asked a question previously about getting exrm working for my project. The answer got me to the point that I can build my release (in dev mode) and access it via the console.

However there are a couple problems:

  1. When I open the console via rel/my_app/bin/my_app console, my application does not actually start. I have to call Application.start(:my_app) to get it going.

  2. Calling rel/my_app/bin/my_app start does not start my app. I can see that the epmd, beam.smp, and run_erl processes have started, but my own application does not appear to be running.

Pretty sure these two problems are related.

Steps taken for console:

$ mix release --dev
$ ./rel/my_app/bin/my_app console
iex([email protected])1> Application.start(:my_app)
# at this point the app is running until I ctrl+c

Steps taken for start:

$ mix release --dev
$ ./rel/my_app/bin/my_app start

$ ps aux | grep "my_app"

12235   0.0  0.0  2460212    636   ??  S    11:10am   0:00.19 /Users/me/code/my_app/rel/my_app/erts-6.3.1/bin/epmd -daemon

17565   0.0  0.2  2524256  26236 s008  Ss+   4:03pm   0:00.37 /Users/me/code/my_app/rel/my_app/erts-6.3.1/bin/beam.smp -- -root /Users/me/code/my_app/rel/my_app -progname Users/me/code/my_app/rel/my_app/bin/my_app -- -home /Users/me -- -boot /Users/me/code/my_app/rel/my_app/releases/0.0.1/my_app -boot_var ERTS_LIB_DIR /Users/me/code/my_app/rel/my_app/erts-6.3.1/../lib -config /Users/me/code/my_app/rel/my_app/releases/0.0.1/sys.config -pa /Users/me/code/my_app/rel/my_app/lib/consolidated -name [email protected] -setcookie my_app -user Elixir.IEx.CLI -extra --no-halt +iex -- console

17562   0.0  0.0  2452008    588   ??  S     4:03pm   0:00.00 /Users/me/code/my_app/rel/my_app/erts-6.3.1/bin/run_erl -daemon /Users/me/code/my_app/rel/my_app/tmp/erl_pipes/my_app/ /Users/me/code/my_app/rel/my_app/log exec "/Users/me/code/my_app/rel/my_app/bin/my_app" "console"

$ tail /var/log/system.log

Jun  9 16:03:14 me.local my_app[17565][17597]: Starting up

I can tell that my application is not running because it should consume from a queue and write to a data store. However when starting the release, the queue is never consumed. Unfortunately I can't find any more log output or errors aside from the one "Starting up" line.

Is there an argument I need to pass to exrm's start command to get it to run my app?

If not, is there perhaps a way to debug this via pointing the logs somewhere or inspecting internal processes?

2

There are 2 answers

2
bitwalker On

Looking at your previously posted mix.exs, you need to add your own application to applications. This tells the VM which applications should be started at runtime. Some applications are started out of the box (such as :kernel, :stdlib, etc.), and you don't need to add those, but anything you wanted started automatically should go in applications. You can put apps which do not need to be started in included_applications, as those are loaded, but not started.

0
BurmajaM On

You need to define your app in mix.exs in order to start it automatically:

def application do
  [applications: [],
   mod: {MyAppModule, []}]
end

So mod: {MyAppModule, []} means that MyAppModule.start_link() will be called automatically.