diff options
Diffstat (limited to 'src/ejabberd.erl')
-rw-r--r-- | src/ejabberd.erl | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/ejabberd.erl b/src/ejabberd.erl index 02b24e5a2..7b83f19a1 100644 --- a/src/ejabberd.erl +++ b/src/ejabberd.erl @@ -27,7 +27,7 @@ -module(ejabberd). -author('alexey@process-one.net'). --export([start/0, stop/0, +-export([start/0, stop/0, start_app/1, get_pid_file/0]). -include("logger.hrl"). @@ -50,3 +50,28 @@ get_pid_file() -> Path -> Path end. + +start_app(App) when not is_list(App) -> + start_app([App]); +start_app([App|Apps]) -> + case application:start(App) of + ok -> + start_app(Apps); + {error, {already_started, _}} -> + start_app(Apps); + {error, {not_started, DepApp}} -> + case lists:member(DepApp, [App|Apps]) of + true -> + ?CRITICAL_MSG("failed to start application '~p': " + "circular dependency on '~p' detected", + [App, DepApp]), + erlang:error(application_start_failed); + false -> + start_app([DepApp,App|Apps]) + end; + Err -> + ?CRITICAL_MSG("failed to start application '~p': ~p", [App, Err]), + erlang:error(application_start_failed) + end; +start_app([]) -> + ok. |