我在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, []}
]}.
我需要自动启动它们(crypto,sasl等)以运行和调试主应用程序。 我发现的唯一解决方案是启动这样的参数:
erl -pa ./ebin -pa ./deps/*/ebin -boot start_sasl -s couchbeam -s crypto -s ibrowse
这是唯一的方法吗?
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
有办法解决吗?
答案 0 :(得分:5)
如果您只是在控制台中搞乱,并且不想输入所有这些'应用程序:start(...)。换行,只需将这些内容放在当前工作目录的.erlang文件中即可。这是我现在正在做的一个例子:
$ cat .erlang
application:start(crypto).
application:start(public_key).
application:start(ssl).
application:start(ibrowse).
application:start(foo).
这会启动我所有的依赖项,然后是我正在处理的应用程序,foo。
如果您想使用钢筋生成reltool版本,此链接可能有所帮助:
When to use erlang application:start or included_applications and a supervisor?
具体来说,这个要点:
https://gist.github.com/3728780
-Todd
答案 1 :(得分:4)
要么你可以向erl发出一系列-eval“application:start(coucnbeam)”命令,要么以正确的OTP方式执行,并使用reltool为你生成一个新的启动文件。
有关reltool的信息,请参阅http://www.erlang.org/doc/man/reltool.html,对于您来说,螺纹钢做了很多繁重工作也是一项非常出色的工作,因此您可能也希望对此进行研究(http://github.com/basho/rebar)
答案 2 :(得分:1)
有一种方法可以启动所有相关的应用程序。 请在http://erlang.org/doc/apps/kernel/application.html#ensure_all_started-1
处查看申请:ensure_all_started API答案 3 :(得分:0)
在你的应用程序回调模块中,只需写:
-module(st_db_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArg) ->
%% Get application name
{ok, AppName} = application:get_application(),
%% Start all dependencies that are not yet started for application name
{ok, _StartedApps} = application:ensure_all_started(AppName),
%% start application's root supervisor or do other initialization here
%% and return root supervisor's pid.