Skip to content

Commit c29e770

Browse files
author
Oliver Ferrigni
committed
Allowing pre_hooks to start applications prior to basho_bench.
Pre_hooks may start crypto ahead of basho_bench. This patch allows basho_bench to continue in the event crypto is already started.
1 parent df56904 commit c29e770

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/basho_bench_app.erl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ start() ->
5050
NotInc when NotInc == {ok, standalone} orelse NotInc == undefined ->
5151
application:load(sasl),
5252
application:set_env(sasl, sasl_error_logger, {file, "log.sasl.txt"}),
53-
ok = application:start(sasl),
54-
5553
%% Make sure crypto is available
56-
ok = application:start(crypto),
54+
ensure_started([sasl, crypto]),
5755

5856
%% Start up our application -- mark it as permanent so that the node
5957
%% will be killed if we go down
@@ -95,3 +93,16 @@ stop(_State) ->
9593
%% ===================================================================
9694
%% Internal functions
9795
%% ===================================================================
96+
97+
ensure_started(Applications) when is_list(Applications) ->
98+
[ensure_started(Application) || Application <- Applications];
99+
100+
ensure_started(Application) ->
101+
case application:start(Application) of
102+
ok ->
103+
ok;
104+
{error, {already_started, Application}} ->
105+
ok;
106+
Error ->
107+
throw(Error)
108+
end.

0 commit comments

Comments
 (0)