Packages

Denrei - a lightweight Erlang messaging system.

Current section

Files

Jump to
denrei src denrei.erl
Raw

src/denrei.erl

%%%-------------------------------------------------------------------
%%% @doc
%%% Denrei - a lightweight Erlang messaging system.
%%% @end
%%%-------------------------------------------------------------------
-module(denrei).
%% API
-export([start/0]).
%% @doc
%% Start the application. Mainly useful for using `-s denrei' as
%% a command line switch to the VM to make lager start on boot.
%% @end
-spec(start() -> 'ok' | {'error', Reason} when Reason :: term()).
start() -> start(denrei).
-spec(start(Application) -> 'ok' | {'error', Reason} when Application :: atom(), Reason :: term()).
start(Application) ->
start(Application, application:start(Application, permanent)).
-spec(start(Application, Result) -> 'ok' | {'error', Reason} when Application :: atom(), Result :: 'ok' | {'error', Reason}, Reason :: term()).
start(_Application, ok) ->
ok;
start(_Application, {error, {already_started, _Application}}) ->
ok;
start(Application, {error, {not_started, Dependency}}) ->
ok = start(Dependency),
start(Application);
start(Application, {error, Reason}) ->
erlang:error({app_start_failed, Application, Reason}).