Erlang:我如何自动启动应用程序的所有必要应用程序?

Dim*_*try 8 erlang

我在st_db.app文件中有必要的应用程序,如下所示:

{application, st_db,
 [
  {description, ""},
  {vsn, "1.0.0"},
  {registered, []},
  {modules, [st_db_app, st_db_sup, st_db]},
  {applications, [
                  kernel,
                  stdlib,
          sasl,
          crypto,
          ibrowse,
          couchbeam
                 ]},
  {mod, { st_db_app, []}},
  {env, []}
 ]}.
Run Code Online (Sandbox Code Playgroud)

我需要自动启动它们(crypto,sasl等)来运行和调试主应用程序.我发现的唯一解决方案是启动这样的参数:

erl -pa ./ebin -pa ./deps/*/ebin -boot start_sasl -s couchbeam -s crypto -s ibrowse 
Run Code Online (Sandbox Code Playgroud)

这是唯一的方法吗?

PS:btw couchbeam不在节点上启动.它只是启动了couchbeam的主管,所以我必须手动运行shell

=PROGRESS REPORT==== 15-Jun-2011::10:22:43 ===
          supervisor: {local,couchbeam_sup}
             started: [{pid,<0.62.0>},
                       {name,couchbeam},
                       {mfargs,{couchbeam,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

2> application:start(couchbeam).
ok
3> 
=PROGRESS REPORT==== 15-Jun-2011::10:23:25 ===
          supervisor: {local,couchbeam_sup}
             started: [{pid,<0.69.0>},
                       {name,couchbeam},
                       {mfargs,{couchbeam,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 15-Jun-2011::10:23:25 ===
         application: couchbeam
          started_at: nonode@nohost
Run Code Online (Sandbox Code Playgroud)

有办法解决吗?

Luk*_*kas 5

您可以向 发出一系列-eval "application:start(coucnbeam)"命令erl,或者以正确的 OTP 方式执行并reltool用于为您生成新的引导文件。

查看有关 reltool 的信息,rebar 在为您完成大部分繁重工作方面也做得非常出色,因此您可能需要查看rebar3

还有一个很棒的章节,来自 LYSE,关于发布。


小智 5

如果你只是在控制台搞乱,并且不想输入所有这些'应用程序:start(...).换行,只需将这些东西放在当前工作目录的.erlang文件中即可.这是我正在进行的工作的一个例子:

$ cat .erlang 
application:start(crypto).
application:start(public_key).
application:start(ssl).
application:start(ibrowse).
application:start(foo).
Run Code Online (Sandbox Code Playgroud)

这将启动我所有的依赖项,然后是我正在处理的应用程序,foo.


如果要使用rebar生成reltool版本,此链接可能会有所帮助:

何时使用erlang应用程序:start或included_applications和主管?

具体来说,这个要点:

https://gist.github.com/3728780

-Todd