Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How run an Erlang application inside the Erlang shell

Tags:

erlang

I have an Erlang application and I can compile it easily and run it by using basho rebar which makes an stand-alone escript executable file. I run it from command line like: ./myapp myconfig.config

My questio is that how can I run it inside Erlang shell. This application has four other applications as dependency. Rebar compile all of the easily. But I need to run this application from inside the shell like:

erl -noshell -name node1@machine -run test start parameter1 -s init stop;

But I don't know in which path I should run it. When I try it in "ebin" folder (where beam files are located), dependencies are not accessible. As I see each dependency applications has it own "ebin" folder. So how can I run my application by "erl -noshell" command (consider dependency applications)? Rebar handles all these things automatically.

like image 509
Sepehr Samini Avatar asked Feb 19 '23 00:02

Sepehr Samini


1 Answers

A typical directory structure for a Rebar-powered OTP application is something like this:

/
  src/
  ebin/
  deps/
    dep1/
      src/
      ebin/
    dep2/
      src/
      ebin/

So, if you're in the root directory of your project, you can point erl to the right place with the -pa argument. To tell it where to find both your application's and its dependencies' BEAM files, try the following:

erl [...] -pa ebin -pa deps/*/ebin
like image 137
Martin Törnwall Avatar answered Mar 04 '23 23:03

Martin Törnwall