Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (114 sloc) 3.982 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, []},
38 permanent, 5000, worker, [yaws_session_server]},
39
21abc5b @klacke Initial revision
authored
40 YawsLog = {yaws_log, {yaws_log, start_link, []},
41 permanent, 5000, worker, [yaws_log]},
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},
21abc5b @klacke Initial revision
authored
45 permanent, 5000, worker, [yaws_server]},
46
fbf6580 Yaws is now RSS capable, see doc/README.rss
Tobbe Tornquist authored
47 YawsRSS = {yaws_rss, {yaws_rss, start_link, []},
48 permanent, 5000, worker, [yaws_rss]},
c5ebd38 @klacke added pam support + prepare for 1.58
authored
49 Pam = {yaws_pam, {yaws_pam, start_link, ["system-auth", false, false]},
50 permanent, 5000, worker, [yaws_pam]},
fbf6580 Yaws is now RSS capable, see doc/README.rss
Tobbe Tornquist authored
51
c5ebd38 @klacke added pam support + prepare for 1.58
authored
52 {ok,{{one_for_all,0,300}, [YawsLog, YawsRSS, YawsServ, Sess, Pam]}}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
53
54 %%----------------------------------------------------------------------
55 %%----------------------------------------------------------------------
56 get_app_args() ->
57 AS=init:get_arguments(),
58 Debug = case application:get_env(yaws, debug) of
59 undefined ->
60 member({yaws, ["debug"]}, AS);
61 {ok, Val} ->
62 Val
63 end,
64 Trace = case application:get_env(yaws, trace) of
65 undefined ->
66 case {member({yaws, ["trace", "http"]}, AS),
67 member({yaws, ["trace", "traffic"]}, AS)} of
68 {true, _} ->
69 {true, http};
70 {_, true} ->
71 {true, traffic};
72 _ ->
73 false
74 end;
75 {ok, http} ->
76 {true, http};
77 {ok, traffic} ->
78 {true, traffic};
79 _ ->
80 false
81 end,
82 TraceOutput = case application:get_env(yaws, traceoutput) of
83 undefined ->
bb9f1ff @klacke better looking debug printouts + dont overwrite trace_to_tty (-x command...
authored
84 member({yaws, ["traceoutput"]}, AS);
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
85 {ok, Val3} ->
86 Val3
87 end,
88 Conf = case application:get_env(yaws, conf) of
89 undefined ->
90 find_c(AS);
91 {ok, File} ->
92 {file, File}
93 end,
94 RunMod = case application:get_env(yaws, runmod) of
95 undefined ->
96 find_runmod(AS);
97 {ok,Mod} ->
98 {ok,Mod}
99 end,
100 Embedded = case application:get_env(yaws, embedded) of
101 undefined ->
102 false;
103 {ok, Emb} ->
104 Emb
105 end,
31fdaae @klacke pam cleanup, add env record, yaws_ls enhancements by doccarcass@gmail.co...
authored
106 #env{debug = Debug, trace = Trace,
107 traceoutput = TraceOutput, conf = Conf,
108 runmod = RunMod, embedded = Embedded}.
9624397 @klacke patch from Fredrik Linder to make it easier to integrate yaws into apps...
authored
109
110 %%----------------------------------------------------------------------
111 %%----------------------------------------------------------------------
112 find_c([{conf, [File]} |_]) ->
113 {file, File};
114 find_c([_|T]) ->
115 find_c(T);
116 find_c([]) ->
117 false.
118
119 %%----------------------------------------------------------------------
120 %%----------------------------------------------------------------------
121 find_runmod([{runmod, [Mod]} |_]) ->
122 {ok,l2a(Mod)};
123 find_runmod([_|T]) ->
124 find_runmod(T);
125 find_runmod([]) ->
126 false.
127
128 %%----------------------------------------------------------------------
129 %%----------------------------------------------------------------------
130 l2a(L) when list(L) -> list_to_atom(L);
131 l2a(A) when atom(A) -> A.
Something went wrong with that request. Please try again.