Permalink
Browse files

added one_for_one supervisor

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1340 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent d422225 commit a0d2c832f2d6bc4feb436979c5ba99685e00a8c9 @klacke committed Jan 13, 2009
Showing with 14 additions and 37 deletions.
  1. +2 −1 src/Makefile
  2. +7 −14 src/yaws_sendfile.erl
  3. +5 −22 src/yaws_sup.erl
View
@@ -38,7 +38,8 @@ MODULES=yaws \
yaws_soap_srv yaws_soap_lib \
authmod_gssapi \
yaws_appmod_cgi \
- yaws_sendfile yaws_sendfile_compat
+ yaws_sendfile yaws_sendfile_compat \
+ yaws_sup_restarts
View
@@ -70,9 +70,9 @@ send(Out, Filename, Offset, Count) ->
call_port(Msg) ->
?MODULE ! {call, self(), Msg},
receive
- {data, <<Count:64/native, 1:8, _/binary>>} ->
+ {?MODULE, {data, <<Count:64/native, 1:8, _/binary>>}} ->
{ok, Count};
- {data, <<_:64/native, 0:8, Error/binary>>} ->
+ {?MODULE, {data, <<_:64/native, 0:8, Error/binary>>}} ->
{error, list_to_atom(
lists:takewhile(fun(El) -> El =/= 0 end,
binary_to_list(Error)))}
@@ -81,21 +81,14 @@ call_port(Msg) ->
loop(Port) ->
receive
{call, Caller, Msg} ->
- try erlang:port_command(Port, Msg) of
- true ->
- receive
- {Port, Response} ->
- Caller ! Response
- end
- catch
- error:badarg ->
- {error, einval};
- error:Reason ->
- {error, Reason}
+ erlang:port_command(Port, Msg),
+ receive
+ {Port, Response} ->
+ Caller ! {?MODULE, Resp}
end,
loop(Port);
stop ->
- try erlang:port_close(Port) catch error:_ -> ok end,
+ erlang:port_close(Port),
receive {'EXIT', Port, _Reason} -> ok
after 0 -> ok
end;
View
@@ -34,43 +34,26 @@ start_link() ->
%%----------------------------------------------------------------------
init([]) ->
- Sess = {yaws_session_server, {yaws_session_server, start_link, []},
- permanent, 5000, worker, [yaws_session_server]},
-
YawsLog = {yaws_log, {yaws_log, start_link, []},
permanent, 5000, worker, [yaws_log]},
YawsServArgs = [_Env = get_app_args()],
YawsServ = {yaws_server, {yaws_server, start_link, YawsServArgs},
permanent, 5000, worker, [yaws_server]},
- YawsRSS = {yaws_rss,
- {yaws_rss, start_link, []},
- permanent, 5000, worker, [yaws_rss]},
-
-
- YawsEventManager = {yaws_event_manager,
- {gen_event, start_link,[{local,yaws_event_manager}]},
- permanent, 5000, worker, [gen_event]},
-
- SendFile = case yaws_sendfile_compat:enabled() of
- true ->
- [{yaws_sendfile,
- {yaws_sendfile_compat, start_link, []},
- permanent, 5000, worker, [yaws_sendfile]}];
- false ->
- []
- end,
+ %% and this guy, will restart auxilliary procs that can fail
+ Sup = {yaws_sup_restarts,
+ {yaws_sup_restarts, start_link, []},
+ transient, infinity, supervisor, [yaws_sup_restarts]},
-
%% The idea behind this is if we're running in an embedded env,
%% typically the supervisor above us wants to control the restarts.
%%
%% If we're running standalone --heart can restart the entire node
%% If heart is not used, we die.
%% 0, 1 means that we never want supervisor restarts
- {ok,{{one_for_all, 0, 1}, [YawsEventManager,YawsLog, YawsRSS, YawsServ, Sess] ++ SendFile}}.
+ {ok,{{one_for_all, 0, 1}, [YawsLog, YawsServ, Sup]}}.
%%----------------------------------------------------------------------
%%----------------------------------------------------------------------

0 comments on commit a0d2c83

Please sign in to comment.