diff --git a/src/mochiweb.erl b/src/mochiweb.erl index 740f5c42..7ba55805 100644 --- a/src/mochiweb.erl +++ b/src/mochiweb.erl @@ -9,6 +9,7 @@ -export([start/0, stop/0]). -export([new_request/1, new_response/1]). -export([all_loaded/0, all_loaded/1, reload/0]). +-export([ensure_started/1]). %% @spec start() -> ok %% @doc Start the MochiWeb server. @@ -77,8 +78,9 @@ new_response({Request, Code, Headers}) -> Code, mochiweb_headers:make(Headers)). -%% Internal API +%% @spec ensure_started(App::atom()) -> ok +%% @doc Start the given App if it has not been started already. ensure_started(App) -> case application:start(App) of ok -> diff --git a/src/mochiweb_socket_server.erl b/src/mochiweb_socket_server.erl index 78b00e2f..bbe1a35b 100644 --- a/src/mochiweb_socket_server.erl +++ b/src/mochiweb_socket_server.erl @@ -119,9 +119,9 @@ parse_options([{profile_fun, ProfileFun} | Rest], State) when is_function(Profil start_server(State=#mochiweb_socket_server{ssl=Ssl, name=Name}) -> _ = case Ssl of true -> - ok = application:start(crypto), - ok = application:start(public_key), - ok = application:start(ssl); + ok = mochiweb:ensure_started(crypto), + ok = mochiweb:ensure_started(public_key), + ok = mochiweb:ensure_started(ssl); false -> void end,