Skip to content

Commit

Permalink
inets: start ssl by default
Browse files Browse the repository at this point in the history
inets will start ssl by default together with its dependencies. the main
reason for this change is that https is almost standard nowadays and
inets:start/0/1/2/3 is a utility function that can benefit from not having to
manually pass new options to allow redirects from http to https
  • Loading branch information
kikofernandez committed Aug 24, 2023
1 parent 0db74ed commit 692532b
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions lib/inets/src/inets_app/inets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
%% Description: Starts the inets application. Default type
%% is temporary. see application(3)
%%--------------------------------------------------------------------
start() ->
start() ->
application:ensure_all_started(ssl),
application:start(inets).

start(Type) ->
start(Type) ->
application:ensure_all_started(ssl),
application:start(inets, Type).


Expand Down Expand Up @@ -92,7 +94,7 @@ start(Service, ServiceConfig, How) ->
%%
%% Description: Stops the inets application.
%%--------------------------------------------------------------------
stop() ->
stop() ->
application:stop(inets).


Expand All @@ -104,12 +106,14 @@ stop() ->
%% Description: Stops a started service of the inets application or takes
%% down a stand alone "service" gracefully.
%%--------------------------------------------------------------------
stop(stand_alone, Pid) ->
true = exit(Pid, shutdown),
ok;

stop(Service, Pid) ->
call_service(Service, stop_service, Pid).
case Service of
stand_alone ->
true = exit(Pid, shutdown),
ok;
_ ->
call_service(Service, stop_service, Pid)
end.


%%--------------------------------------------------------------------
Expand All @@ -119,16 +123,13 @@ stop(Service, Pid) ->
%% Note: Services started with the stand alone option will not be listed
%%--------------------------------------------------------------------
services() ->
try lists:flatten(lists:map(fun(Module) ->
Module:services()
end, service_names())) of
Result ->
Result
catch
exit:{noproc, _} ->
try
lists:flatmap(fun(Module) -> Module:services() end, service_names())
catch
exit:{noproc, _} ->
{error, inets_not_started}
end.


%%--------------------------------------------------------------------
%% Function: services_info() -> [{Service, Pid, Info}]
Expand All @@ -138,20 +139,20 @@ services() ->
%%--------------------------------------------------------------------
services_info() ->
case services() of
{error, inets_not_started} ->
{error, inets_not_started};
Services ->
Fun = fun({Service, Pid}) ->
Info =
case Service:service_info(Pid) of
{ok, PropList} ->
PropList;
{error, Reason} ->
Reason
end,
{Service, Pid, Info}
end,
lists:flatten(lists:map(Fun, Services))
{error, inets_not_started} ->
{error, inets_not_started};
Services ->
Fun = fun({Service, Pid}) ->
Info =
case Service:service_info(Pid) of
{ok, PropList} ->
PropList;
{error, Reason} ->
Reason
end,
{Service, Pid, Info}
end,
lists:flatmap(Fun, Services)
end.


Expand Down Expand Up @@ -434,10 +435,12 @@ report_event(Severity, Label, Service, Content) ->
%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
start_service(Service, Args, stand_alone) ->
Service:start_standalone(Args);
start_service(Service, Args, inets) ->
call_service(Service, start_service, Args).
start_service(Service, Args, How) ->
application:ensure_all_started(ssl),
case How of
stand_alone -> Service:start_standalone(Args);
inets -> call_service(Service, start_service, Args)
end.

call_service(Service, Call, Args) ->
try Service:Call(Args) of
Expand Down

0 comments on commit 692532b

Please sign in to comment.