Skip to content
This repository
Newer
Older
100644 142 lines (124 sloc) 4.963 kb
21abc5ba »
2002-02-11 Initial revision
1 %%%----------------------------------------------------------------------
2 %%% File : yaws_sup.erl
3 %%% Author : Claes Wikstrom <klacke@bluetail.com>
4 %%% Purpose :
5 %%% Created : 16 Jan 2002 by Claes Wikstrom <klacke@bluetail.com>
6 %%%----------------------------------------------------------------------
7
8 -module(yaws_sup).
9 -author('klacke@bluetail.com').
31fdaae8 »
2006-02-14 pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail…
10 -include("../include/yaws.hrl").
21abc5ba »
2002-02-11 Initial revision
11
12 -behaviour(supervisor).
13
14 %% External exports
15 -export([start_link/0]).
16
17 %% supervisor callbacks
18 -export([init/1]).
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
19 -export([get_app_args/0]).
20
21 -import(lists, [member/2]).
21abc5ba »
2002-02-11 Initial revision
22
23 %%%----------------------------------------------------------------------
24 %%% API
25 %%%----------------------------------------------------------------------
26 start_link() ->
27 supervisor:start_link({local, ?MODULE}, ?MODULE, []).
28
29 %%%----------------------------------------------------------------------
30 %%% Callback functions from supervisor
31 %%%----------------------------------------------------------------------
32
33 %%----------------------------------------------------------------------
34 %%----------------------------------------------------------------------
35 init([]) ->
80771c86 »
2002-09-17 cache_refresh to 0 if debug, added a cookie_session-server for persis…
36
21abc5ba »
2002-02-11 Initial revision
37 YawsLog = {yaws_log, {yaws_log, start_link, []},
0be3c7e8 »
2008-02-14 untabified all of yaws
38 permanent, 5000, worker, [yaws_log]},
21abc5ba »
2002-02-11 Initial revision
39
4bead70a »
2008-05-17 The supervisor args were wrong, yaws shall have 1,0 restart strategy
40 YawsServArgs = [_Env = get_app_args()],
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
41 YawsServ = {yaws_server, {yaws_server, start_link, YawsServArgs},
0be3c7e8 »
2008-02-14 untabified all of yaws
42 permanent, 5000, worker, [yaws_server]},
21abc5ba »
2002-02-11 Initial revision
43
a0d2c832 »
2009-01-13 added one_for_one supervisor
44 %% and this guy, will restart auxilliary procs that can fail
45 Sup = {yaws_sup_restarts,
46 {yaws_sup_restarts, start_link, []},
47 transient, infinity, supervisor, [yaws_sup_restarts]},
12471ad5 »
2008-12-20 added configure support for sendfile
48
49
4bead70a »
2008-05-17 The supervisor args were wrong, yaws shall have 1,0 restart strategy
50 %% The idea behind this is if we're running in an embedded env,
51 %% typically the supervisor above us wants to control the restarts.
52 %%
53 %% If we're running standalone --heart can restart the entire node
54 %% If heart is not used, we die.
55 %% 0, 1 means that we never want supervisor restarts
a0d2c832 »
2009-01-13 added one_for_one supervisor
56 {ok,{{one_for_all, 0, 1}, [YawsLog, YawsServ, Sup]}}.
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
57
58 %%----------------------------------------------------------------------
59 %%----------------------------------------------------------------------
60 get_app_args() ->
61 AS=init:get_arguments(),
62 Debug = case application:get_env(yaws, debug) of
0be3c7e8 »
2008-02-14 untabified all of yaws
63 undefined ->
64 member({yaws, ["debug"]}, AS);
65 {ok, Val} ->
66 Val
67 end,
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
68 Trace = case application:get_env(yaws, trace) of
0be3c7e8 »
2008-02-14 untabified all of yaws
69 undefined ->
70 case {member({yaws, ["trace", "http"]}, AS),
71 member({yaws, ["trace", "traffic"]}, AS)} of
72 {true, _} ->
73 {true, http};
74 {_, true} ->
75 {true, traffic};
76 _ ->
77 false
78 end;
79 {ok, http} ->
80 {true, http};
81 {ok, traffic} ->
82 {true, traffic};
83 _ ->
84 false
85 end,
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
86 TraceOutput = case application:get_env(yaws, traceoutput) of
0be3c7e8 »
2008-02-14 untabified all of yaws
87 undefined ->
88 member({yaws, ["traceoutput"]}, AS);
89 {ok, Val3} ->
90 Val3
91 end,
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
92 Conf = case application:get_env(yaws, conf) of
0be3c7e8 »
2008-02-14 untabified all of yaws
93 undefined ->
94 find_c(AS);
95 {ok, File} ->
96 {file, File}
97 end,
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
98 RunMod = case application:get_env(yaws, runmod) of
0be3c7e8 »
2008-02-14 untabified all of yaws
99 undefined ->
100 find_runmod(AS);
101 {ok,Mod} ->
102 {ok,Mod}
103 end,
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
104 Embedded = case application:get_env(yaws, embedded) of
0be3c7e8 »
2008-02-14 untabified all of yaws
105 undefined ->
106 false;
107 {ok, Emb} ->
108 Emb
109 end,
92bafb48 »
2006-03-09 removed the ability change userid, also stopped writing to /tmp/yaws …
110 Id = case application:get_env(yaws, id) of
0be3c7e8 »
2008-02-14 untabified all of yaws
111 undefined ->
112 "default";
113 {ok, Id0} ->
114 Id0
115 end,
92bafb48 »
2006-03-09 removed the ability change userid, also stopped writing to /tmp/yaws …
116
31fdaae8 »
2006-02-14 pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail…
117 #env{debug = Debug, trace = Trace,
0be3c7e8 »
2008-02-14 untabified all of yaws
118 traceoutput = TraceOutput, conf = Conf,
119 runmod = RunMod, embedded = Embedded, id = Id}.
96243974 »
2004-06-04 patch from Fredrik Linder to make it easier to integrate yaws into ap…
120
121 %%----------------------------------------------------------------------
122 %%----------------------------------------------------------------------
123 find_c([{conf, [File]} |_]) ->
124 {file, File};
125 find_c([_|T]) ->
126 find_c(T);
127 find_c([]) ->
128 false.
129
130 %%----------------------------------------------------------------------
131 %%----------------------------------------------------------------------
132 find_runmod([{runmod, [Mod]} |_]) ->
133 {ok,l2a(Mod)};
134 find_runmod([_|T]) ->
135 find_runmod(T);
136 find_runmod([]) ->
137 false.
138
139 %%----------------------------------------------------------------------
140 %%----------------------------------------------------------------------
141 l2a(L) when list(L) -> list_to_atom(L);
142 l2a(A) when atom(A) -> A.
Something went wrong with that request. Please try again.