Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 160 lines (136 sloc) 5.596 kB
21abc5b @klacke Initial revision
authored
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').
31fdaae @klacke pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail…
authored
10 -include("../include/yaws.hrl").
21abc5b @klacke Initial revision
authored
11
12 -behaviour(supervisor).
13
14 %% External exports
15 -export([start_link/0]).
16
17 %% supervisor callbacks
18 -export([init/1]).
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
19 -export([get_app_args/0]).
20
21 -import(lists, [member/2]).
21abc5b @klacke Initial revision
authored
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([]) ->
80771c8 @klacke cache_refresh to 0 if debug, added a cookie_session-server for persis…
authored
36
37 Sess = {yaws_session_server, {yaws_session_server, start_link, []},
0be3c7e @klacke untabified all of yaws
authored
38 permanent, 5000, worker, [yaws_session_server]},
80771c8 @klacke cache_refresh to 0 if debug, added a cookie_session-server for persis…
authored
39
21abc5b @klacke Initial revision
authored
40 YawsLog = {yaws_log, {yaws_log, start_link, []},
0be3c7e @klacke untabified all of yaws
authored
41 permanent, 5000, worker, [yaws_log]},
21abc5b @klacke Initial revision
authored
42
4bead70 @klacke The supervisor args were wrong, yaws shall have 1,0 restart strategy
authored
43 YawsServArgs = [_Env = get_app_args()],
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
44 YawsServ = {yaws_server, {yaws_server, start_link, YawsServArgs},
0be3c7e @klacke untabified all of yaws
authored
45 permanent, 5000, worker, [yaws_server]},
21abc5b @klacke Initial revision
authored
46
12471ad @klacke added configure support for sendfile
authored
47 YawsRSS = {yaws_rss,
48 {yaws_rss, start_link, []},
0be3c7e @klacke untabified all of yaws
authored
49 permanent, 5000, worker, [yaws_rss]},
12471ad @klacke added configure support for sendfile
authored
50
fbf6580 Yaws is now RSS capable, see doc/README.rss
Tobbe Tornquist authored
51
11a8274 @klacke mikl hup fixes
authored
52 YawsEventManager = {yaws_event_manager,
0be3c7e @klacke untabified all of yaws
authored
53 {gen_event, start_link,[{local,yaws_event_manager}]},
54 permanent, 5000, worker, [gen_event]},
11a8274 @klacke mikl hup fixes
authored
55
12471ad @klacke added configure support for sendfile
authored
56 SendFile = case yaws_sendfile_compat:enabled() of
57 true ->
58 [{yaws_sendfile,
59 {yaws_sendfile_compat, start_link, []},
60 permanent, 5000, worker, [yaws_sendfile]}];
61 false ->
62 []
63 end,
64
65
66
4bead70 @klacke The supervisor args were wrong, yaws shall have 1,0 restart strategy
authored
67 %% The idea behind this is if we're running in an embedded env,
68 %% typically the supervisor above us wants to control the restarts.
69 %%
70 %% If we're running standalone --heart can restart the entire node
71 %% If heart is not used, we die.
72 %% 0, 1 means that we never want supervisor restarts
12471ad @klacke added configure support for sendfile
authored
73 {ok,{{one_for_all, 0, 1}, [YawsEventManager,YawsLog, YawsRSS, YawsServ, Sess] ++ SendFile}}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
74
75 %%----------------------------------------------------------------------
76 %%----------------------------------------------------------------------
77 get_app_args() ->
78 AS=init:get_arguments(),
79 Debug = case application:get_env(yaws, debug) of
0be3c7e @klacke untabified all of yaws
authored
80 undefined ->
81 member({yaws, ["debug"]}, AS);
82 {ok, Val} ->
83 Val
84 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
85 Trace = case application:get_env(yaws, trace) of
0be3c7e @klacke untabified all of yaws
authored
86 undefined ->
87 case {member({yaws, ["trace", "http"]}, AS),
88 member({yaws, ["trace", "traffic"]}, AS)} of
89 {true, _} ->
90 {true, http};
91 {_, true} ->
92 {true, traffic};
93 _ ->
94 false
95 end;
96 {ok, http} ->
97 {true, http};
98 {ok, traffic} ->
99 {true, traffic};
100 _ ->
101 false
102 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
103 TraceOutput = case application:get_env(yaws, traceoutput) of
0be3c7e @klacke untabified all of yaws
authored
104 undefined ->
105 member({yaws, ["traceoutput"]}, AS);
106 {ok, Val3} ->
107 Val3
108 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
109 Conf = case application:get_env(yaws, conf) of
0be3c7e @klacke untabified all of yaws
authored
110 undefined ->
111 find_c(AS);
112 {ok, File} ->
113 {file, File}
114 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
115 RunMod = case application:get_env(yaws, runmod) of
0be3c7e @klacke untabified all of yaws
authored
116 undefined ->
117 find_runmod(AS);
118 {ok,Mod} ->
119 {ok,Mod}
120 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
121 Embedded = case application:get_env(yaws, embedded) of
0be3c7e @klacke untabified all of yaws
authored
122 undefined ->
123 false;
124 {ok, Emb} ->
125 Emb
126 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws …
authored
127 Id = case application:get_env(yaws, id) of
0be3c7e @klacke untabified all of yaws
authored
128 undefined ->
129 "default";
130 {ok, Id0} ->
131 Id0
132 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws …
authored
133
31fdaae @klacke pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail…
authored
134 #env{debug = Debug, trace = Trace,
0be3c7e @klacke untabified all of yaws
authored
135 traceoutput = TraceOutput, conf = Conf,
136 runmod = RunMod, embedded = Embedded, id = Id}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
137
138 %%----------------------------------------------------------------------
139 %%----------------------------------------------------------------------
140 find_c([{conf, [File]} |_]) ->
141 {file, File};
142 find_c([_|T]) ->
143 find_c(T);
144 find_c([]) ->
145 false.
146
147 %%----------------------------------------------------------------------
148 %%----------------------------------------------------------------------
149 find_runmod([{runmod, [Mod]} |_]) ->
150 {ok,l2a(Mod)};
151 find_runmod([_|T]) ->
152 find_runmod(T);
153 find_runmod([]) ->
154 false.
155
156 %%----------------------------------------------------------------------
157 %%----------------------------------------------------------------------
158 l2a(L) when list(L) -> list_to_atom(L);
159 l2a(A) when atom(A) -> A.
Something went wrong with that request. Please try again.