使用命令行args启动erlang工作,args_file没有

时间:2013-03-05 19:51:49

标签: command-line erlang erl

我通过遵循令人惊讶的“如何在10分钟内使用Erlang创建HTTP API”来在erlang中构建一个非常简单的小OTP应用程序:

https://vimeo.com/59832641

当我使用命令行参数启动erl时,它非常有效,如视频中所示。但是,如果我尝试使用-args_file参数启动erl,则应用程序无法启动。

args_file非常简单;它只有一行,如下:

-pa deps/*/ebin ebin -s fancyapi_app

...这是我尝试运行erlang时得到的错误报告:

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

有什么想法吗? args_file FileName是否比仅使用常规命令行参数更容易发生?文档位于:

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

此外,我知道该命令在某种程度上有效,因为如果我在文本文件中添加-sname node,则erl提示符会显示(node@localhost)1>

1 个答案:

答案 0 :(得分:4)

使用-emu_args标志,该标志将显示发送到模拟器的确切参数。以下是一个简单的示例:

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

现在我将手动传递所有这些参数:

$ 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> 

接下来通过args文件:

$ 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> 

正如你所看到的,两者真的不一样。具体来说,手动执行此操作-pa deps/*/ebin会扩展为-pa deps/cowboy/ebin deps/jsx/ebin ...,但是当您通过args文件传递时,同样不会很好。因此,某些模块不在您的代码路径中,因此应用程序无法启动。

相关问题