Question

I rigged up a very simple little OTP application in erlang by following the amazing "How to create a HTTP API with Erlang in 10 Minutes":

https://vimeo.com/59832641

It works perfectly when I start erl with command line args as demonstrated in the video. However, if I try to start erl with the -args_file argument, the application does not start.

The args_file is incredibly simple; it has only one line, as follows:

-pa deps/*/ebin ebin -s fancyapi_app

...and here's the error report I get when I try to run erlang:

=INFO REPORT==== 5-Mar-2013::19:32:59 ===
application: fancyapi
exited: {shutdown,{fancyapi_app,start,[normal,[]]}}
type: temporary

Any ideas? Does args_file FileName cause more to happen than just using regular command line args? Documentation is at:

http://www.erlang.org/doc/man/erl.html

Furthermore, I know the command is working to an extent because if I add, say -sname node to the text file, the erl prompt shows (node@localhost)1>.

Was it helpful?

Solution

Make use of -emu_args flag which will show exact arguments sent to the emulator. Here is a simple sample to play with:

$ cat test.args 
-emu_args
-pa deps/*/ebin
-pa ebin
-name test@localhost

Now for once I will pass all these arguments manually:

$ erl -emu_args -pa deps/*/ebin -pa ebin -name test@localhost
Executing: /Users/abhinavsingh/Builds/R15B03/lib/erlang/erts-5.9.3.1/bin/beam.smp /Users/abhinavsingh/Builds/R15B03/lib/erlang/erts-5.9.3.1/bin/beam.smp -- -root /Users/abhinavsingh/Builds/R15B03/lib/erlang -progname erl -- -home /Users/abhinavsingh -- -pa deps/cowboy/ebin deps/jsx/ebin deps/lager/ebin deps/mimetypes/ebin deps/ranch/ebin -pa ebin -name test@localhost

Erlang R15B03 (erts-5.9.3.1) [source] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.3.1  (abort with ^G)
(test@localhost)1> 

Next via args file:

$ erl -args_file test.args 
Executing: /Users/abhinavsingh/Builds/R15B03/lib/erlang/erts-5.9.3.1/bin/beam.smp /Users/abhinavsingh/Builds/R15B03/lib/erlang/erts-5.9.3.1/bin/beam.smp -- -root /Users/abhinavsingh/Builds/R15B03/lib/erlang -progname erl -- -home /Users/abhinavsingh -- -pa deps/*/ebin -pa ebin -name test@localhost

Erlang R15B03 (erts-5.9.3.1) [source] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.3.1  (abort with ^G)
(test@localhost)1> 

As you can see, both are really not the same. Specifically, while doing it all manually -pa deps/*/ebin expands into -pa deps/cowboy/ebin deps/jsx/ebin ..., but the same doesn't go down well when you pass it via args file. As as result, certain modules are not in your code path and thus application fails to start.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top