Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 154 lines (133 sloc) 5.395 kb
21abc5b @klacke Initial revision
authored
1 %%%----------------------------------------------------------------------
2 %%% File : yaws_sup.erl
3 %%% Author : Claes Wikstrom <klacke@bluetail.com>
455578a @vinoski major trailing whitespace cleanup
vinoski authored
4 %%% Purpose :
21abc5b @klacke Initial revision
authored
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]).
6b26557 @vinoski improved embedded support
vinoski authored
19 -export([get_app_args/0, child_specs/0]).
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
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
6b26557 @vinoski improved embedded support
vinoski authored
37 ChildSpecs = child_specs(),
38
455578a @vinoski major trailing whitespace cleanup
vinoski authored
39 %% The idea behind this is if we're running in an embedded env,
6b26557 @vinoski improved embedded support
vinoski authored
40 %% typically the supervisor above us wants to control the restarts.
455578a @vinoski major trailing whitespace cleanup
vinoski authored
41 %%
6b26557 @vinoski improved embedded support
vinoski authored
42 %% If we're running standalone --heart can restart the entire node
43 %% If heart is not used, we die.
44 %% 0, 1 means that we never want supervisor restarts
45 {ok,{{one_for_all, 0, 1}, ChildSpecs}}.
46
47 %%----------------------------------------------------------------------
48 %%----------------------------------------------------------------------
49 child_specs() ->
21abc5b @klacke Initial revision
authored
50 YawsLog = {yaws_log, {yaws_log, start_link, []},
0be3c7e @klacke untabified all of yaws
authored
51 permanent, 5000, worker, [yaws_log]},
21abc5b @klacke Initial revision
authored
52
082d55c Add new module to deal with trace files
Christopher Faulet authored
53 YawsTrace = {yaws_trace, {yaws_trace, start_link, []},
54 permanent, 5000, worker, [yaws_trace]},
55
4bead70 @klacke The supervisor args were wrong, yaws shall have 1,0 restart strategy
authored
56 YawsServArgs = [_Env = get_app_args()],
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
57 YawsServ = {yaws_server, {yaws_server, start_link, YawsServArgs},
c075573 soft yaws shutdown (capflam)
Christopher Faulet authored
58 permanent, 120000, worker, [yaws_server]},
21abc5b @klacke Initial revision
authored
59
6b26557 @vinoski improved embedded support
vinoski authored
60 %% and this guy will restart auxiliary procs that can fail
a0d2c83 @klacke added one_for_one supervisor
authored
61 Sup = {yaws_sup_restarts,
62 {yaws_sup_restarts, start_link, []},
63 transient, infinity, supervisor, [yaws_sup_restarts]},
12471ad @klacke added configure support for sendfile
authored
64
a6706eb @vinoski Move WebDAV to an appmod, the locking server to a runmod (tjeerd)
vinoski authored
65 [YawsLog, YawsTrace, YawsServ, Sup].
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
66
67 %%----------------------------------------------------------------------
68 %%----------------------------------------------------------------------
69 get_app_args() ->
70 AS=init:get_arguments(),
71 Debug = case application:get_env(yaws, debug) of
0be3c7e @klacke untabified all of yaws
authored
72 undefined ->
73 member({yaws, ["debug"]}, AS);
74 {ok, Val} ->
75 Val
76 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
77 Trace = case application:get_env(yaws, trace) of
0be3c7e @klacke untabified all of yaws
authored
78 undefined ->
79 case {member({yaws, ["trace", "http"]}, AS),
80 member({yaws, ["trace", "traffic"]}, AS)} of
81 {true, _} ->
82 {true, http};
83 {_, true} ->
84 {true, traffic};
85 _ ->
86 false
87 end;
88 {ok, http} ->
89 {true, http};
90 {ok, traffic} ->
91 {true, traffic};
92 _ ->
93 false
94 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
95 TraceOutput = case application:get_env(yaws, traceoutput) of
0be3c7e @klacke untabified all of yaws
authored
96 undefined ->
97 member({yaws, ["traceoutput"]}, AS);
98 {ok, Val3} ->
99 Val3
100 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
101 Conf = case application:get_env(yaws, conf) of
0be3c7e @klacke untabified all of yaws
authored
102 undefined ->
103 find_c(AS);
104 {ok, File} ->
105 {file, File}
106 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
107 RunMod = case application:get_env(yaws, runmod) of
0be3c7e @klacke untabified all of yaws
authored
108 undefined ->
109 find_runmod(AS);
110 {ok,Mod} ->
111 {ok,Mod}
112 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
113 Embedded = case application:get_env(yaws, embedded) of
0be3c7e @klacke untabified all of yaws
authored
114 undefined ->
115 false;
116 {ok, Emb} ->
117 Emb
118 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws …
authored
119 Id = case application:get_env(yaws, id) of
0be3c7e @klacke untabified all of yaws
authored
120 undefined ->
121 "default";
d63642e @vinoski do not pass the --id option if the default id is used
vinoski authored
122 {ok, Id0} when is_atom(Id0) ->
123 atom_to_list(Id0);
0be3c7e @klacke untabified all of yaws
authored
124 {ok, Id0} ->
125 Id0
126 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws …
authored
127
455578a @vinoski major trailing whitespace cleanup
vinoski authored
128 #env{debug = Debug, trace = Trace,
129 traceoutput = TraceOutput, conf = Conf,
0be3c7e @klacke untabified all of yaws
authored
130 runmod = RunMod, embedded = Embedded, id = Id}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into a…
authored
131
132 %%----------------------------------------------------------------------
133 %%----------------------------------------------------------------------
134 find_c([{conf, [File]} |_]) ->
135 {file, File};
136 find_c([_|T]) ->
137 find_c(T);
138 find_c([]) ->
139 false.
140
141 %%----------------------------------------------------------------------
142 %%----------------------------------------------------------------------
143 find_runmod([{runmod, [Mod]} |_]) ->
144 {ok,l2a(Mod)};
145 find_runmod([_|T]) ->
146 find_runmod(T);
147 find_runmod([]) ->
148 false.
149
150 %%----------------------------------------------------------------------
151 %%----------------------------------------------------------------------
f44be6a @klacke all calls to old deprecated guard tests removed
authored
152 l2a(L) when is_list(L) -> list_to_atom(L);
153 l2a(A) when is_atom(A) -> A.
Something went wrong with that request. Please try again.