Erlang, how to download applications with their dependencies

I have several applications in my cluster, I sometimes need to run some of them on different hosts.

The story is that the Erlang cluster is already running, so despite the fact that I have an .app resource file for each application, which indicates which applications should be launched before mine, this only works to create a launch script, not to run in an already running node.

Currently, I have a custom routine that uses the application: get_key (application, applications) to retrieve the dependencies and runs them separately before starting this application.

I was wondering if there is a better way to do this.

+5
source share
4

script . smarts, , , .

, , Mochiweb . :

-module(some_app).
-export([start/0, stop/0]).

ensure_started(App) ->
    case application:start(App) of
        ok ->
            ok;
        {error, {already_started, App}} ->
            ok
    end.

%% @spec start() -> ok
%% @doc Start the some_app server.
start() ->
    some_app_deps:ensure(),
    ensure_started(crypto),
    application:start(some_app).

%% @spec stop() -> ok
%% @doc Stop the some_app server.
stop() ->
    application:stop(some_app).
+1
+12

, Erlang . :

-module(myapp_app).
-export([start/0]).

start() -> a_start(myapp, permanent).

a_start(App, Type) ->
    start_ok(App, Type, application:start(App, Type)).

start_ok(_App, _Type, ok) -> ok;
start_ok(_App, _Type, {error, {already_started, _App}}) -> ok;
start_ok(App, Type, {error, {not_started, Dep}}) ->
    ok = a_start(Dep, Type),
    a_start(App, Type);
start_ok(App, _Type, {error, Reason}) ->
    erlang:error({app_start_failed, App, Reason}).

-s myapp_app erlang, . , :)


Erbang Factory 2012 SFBay erlang.

+6

" OTP", yourappname.app, "". , . :

All applications that must be running before this application is launched. systools uses this list to generate the correct boot scripts. The default is [], but note that all applications have dependencies, at least on the kernel and stdlib.

Therefore, if you use releases, this resolution of dependencies will be resolved using systools.

0
source

All Articles