Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 142 lines (122 sloc) 4.915 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.co...
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 apps...
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 persistan...
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 persistan...
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
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
43 YawsServArgs = [get_app_args()],
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
fbf6580 Yaws is now RSS capable, see doc/README.rss
Tobbe Tornquist authored
47 YawsRSS = {yaws_rss, {yaws_rss, start_link, []},
0be3c7e @klacke untabified all of yaws
authored
48 permanent, 5000, worker, [yaws_rss]},
fbf6580 Yaws is now RSS capable, see doc/README.rss
Tobbe Tornquist authored
49
11a8274 @klacke mikl hup fixes
authored
50 YawsEventManager = {yaws_event_manager,
0be3c7e @klacke untabified all of yaws
authored
51 {gen_event, start_link,[{local,yaws_event_manager}]},
52 permanent, 5000, worker, [gen_event]},
11a8274 @klacke mikl hup fixes
authored
53
0be3c7e @klacke untabified all of yaws
authored
54 {ok,{{one_for_all,10,30}, [YawsLog, YawsRSS, YawsServ, Sess,
55 YawsEventManager]}}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
56
57 %%----------------------------------------------------------------------
58 %%----------------------------------------------------------------------
59 get_app_args() ->
60 AS=init:get_arguments(),
61 Debug = case application:get_env(yaws, debug) of
0be3c7e @klacke untabified all of yaws
authored
62 undefined ->
63 member({yaws, ["debug"]}, AS);
64 {ok, Val} ->
65 Val
66 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
67 Trace = case application:get_env(yaws, trace) of
0be3c7e @klacke untabified all of yaws
authored
68 undefined ->
69 case {member({yaws, ["trace", "http"]}, AS),
70 member({yaws, ["trace", "traffic"]}, AS)} of
71 {true, _} ->
72 {true, http};
73 {_, true} ->
74 {true, traffic};
75 _ ->
76 false
77 end;
78 {ok, http} ->
79 {true, http};
80 {ok, traffic} ->
81 {true, traffic};
82 _ ->
83 false
84 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
85 TraceOutput = case application:get_env(yaws, traceoutput) of
0be3c7e @klacke untabified all of yaws
authored
86 undefined ->
87 member({yaws, ["traceoutput"]}, AS);
88 {ok, Val3} ->
89 Val3
90 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
91 Conf = case application:get_env(yaws, conf) of
0be3c7e @klacke untabified all of yaws
authored
92 undefined ->
93 find_c(AS);
94 {ok, File} ->
95 {file, File}
96 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
97 RunMod = case application:get_env(yaws, runmod) of
0be3c7e @klacke untabified all of yaws
authored
98 undefined ->
99 find_runmod(AS);
100 {ok,Mod} ->
101 {ok,Mod}
102 end,
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
103 Embedded = case application:get_env(yaws, embedded) of
0be3c7e @klacke untabified all of yaws
authored
104 undefined ->
105 false;
106 {ok, Emb} ->
107 Emb
108 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws and...
authored
109 Id = case application:get_env(yaws, id) of
0be3c7e @klacke untabified all of yaws
authored
110 undefined ->
111 "default";
112 {ok, Id0} ->
113 Id0
114 end,
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws and...
authored
115
31fdaae @klacke pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail.co...
authored
116 #env{debug = Debug, trace = Trace,
0be3c7e @klacke untabified all of yaws
authored
117 traceoutput = TraceOutput, conf = Conf,
118 runmod = RunMod, embedded = Embedded, id = Id}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
119
120 %%----------------------------------------------------------------------
121 %%----------------------------------------------------------------------
122 find_c([{conf, [File]} |_]) ->
123 {file, File};
124 find_c([_|T]) ->
125 find_c(T);
126 find_c([]) ->
127 false.
128
129 %%----------------------------------------------------------------------
130 %%----------------------------------------------------------------------
131 find_runmod([{runmod, [Mod]} |_]) ->
132 {ok,l2a(Mod)};
133 find_runmod([_|T]) ->
134 find_runmod(T);
135 find_runmod([]) ->
136 false.
137
138 %%----------------------------------------------------------------------
139 %%----------------------------------------------------------------------
140 l2a(L) when list(L) -> list_to_atom(L);
141 l2a(A) when atom(A) -> A.
Something went wrong with that request. Please try again.