Permalink
Browse files

Export ensure_started and use it in the socket server.

  • Loading branch information...
1 parent 5199163 commit a1103252ccaeaf1650ef042810289de71aa636ca David Reid committed Apr 9, 2011
Showing with 6 additions and 4 deletions.
  1. +3 −1 src/mochiweb.erl
  2. +3 −3 src/mochiweb_socket_server.erl
View
4 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 ->
View
6 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,

0 comments on commit a110325

Please sign in to comment.