~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/r9c_tests_SUITE_data/src/inets/inets_sup.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% ``The contents of this file are subject to the Erlang Public License,
 
2
%% Version 1.1, (the "License"); you may not use this file except in
 
3
%% compliance with the License. You should have received a copy of the
 
4
%% Erlang Public License along with this software. If not, it can be
 
5
%% retrieved via the world wide web at http://www.erlang.org/.
 
6
%% 
 
7
%% Software distributed under the License is distributed on an "AS IS"
 
8
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
9
%% the License for the specific language governing rights and limitations
 
10
%% under the License.
 
11
%% 
 
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
 
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
 
14
%% AB. All Rights Reserved.''
 
15
%% 
 
16
%%     $Id: inets_sup.erl,v 1.1 2008/12/17 09:53:34 mikpe Exp $
 
17
%%
 
18
-module(inets_sup).
 
19
 
 
20
-export([crock/0]).
 
21
-export([start/2, stop/1, init/1]).
 
22
-export([start_child/2, stop_child/2, which_children/0]).
 
23
 
 
24
 
 
25
%% crock (Used for debugging!)
 
26
 
 
27
crock() ->
 
28
    application:start(sasl),
 
29
    application:start(inets).
 
30
 
 
31
 
 
32
%% start
 
33
 
 
34
start(Type, State) ->
 
35
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
 
36
 
 
37
 
 
38
%% stop
 
39
 
 
40
stop(State) ->
 
41
    ok.
 
42
 
 
43
 
 
44
%% start_child
 
45
 
 
46
start_child(ConfigFile, Verbosity) ->
 
47
    {ok, Spec} = httpd_child_spec(ConfigFile, Verbosity),
 
48
    supervisor:start_child(?MODULE, Spec).
 
49
    
 
50
 
 
51
%% stop_child
 
52
 
 
53
stop_child(Addr, Port) ->
 
54
    Name = {httpd_sup, Addr, Port},
 
55
    case supervisor:terminate_child(?MODULE, Name) of
 
56
        ok ->
 
57
            supervisor:delete_child(?MODULE, Name);
 
58
        Error ->
 
59
            Error
 
60
    end.
 
61
    
 
62
 
 
63
%% which_children
 
64
 
 
65
which_children() ->
 
66
    supervisor:which_children(?MODULE).
 
67
    
 
68
 
 
69
%% init
 
70
 
 
71
init([]) ->
 
72
    case get_services() of
 
73
        {error, Reason} ->
 
74
            {error,Reason};
 
75
        Services ->
 
76
            SupFlags = {one_for_one, 10, 3600},
 
77
            {ok, {SupFlags, child_spec(Services, [])}}
 
78
    end.
 
79
 
 
80
get_services() ->
 
81
    case (catch application:get_env(inets, services)) of
 
82
        {ok, Services} ->
 
83
            Services;
 
84
        _ ->
 
85
            []
 
86
    end.
 
87
 
 
88
 
 
89
child_spec([], Acc) ->
 
90
    Acc;
 
91
child_spec([{httpd, ConfigFile, Verbosity}|Rest], Acc) ->
 
92
    case httpd_child_spec(ConfigFile, Verbosity) of
 
93
        {ok, Spec} ->
 
94
            child_spec(Rest, [Spec | Acc]);
 
95
        {error, Reason} ->
 
96
            error_msg("Failed creating child spec "
 
97
                      "using ~p for reason: ~p", [ConfigFile, Reason]),
 
98
            child_spec(Rest, Acc)
 
99
    end;
 
100
child_spec([{httpd, ConfigFile}|Rest], Acc) ->
 
101
    case httpd_child_spec(ConfigFile, []) of
 
102
        {ok, Spec} ->
 
103
            child_spec(Rest, [Spec | Acc]);
 
104
        {error, Reason} ->
 
105
            error_msg("Failed creating child spec "
 
106
                      "using ~p for reason: ~p", [ConfigFile, Reason]),
 
107
            child_spec(Rest, Acc)
 
108
    end.
 
109
 
 
110
 
 
111
httpd_child_spec(ConfigFile, Verbosity) ->
 
112
    case httpd_conf:load(ConfigFile) of
 
113
        {ok, ConfigList} ->
 
114
            Port = httpd_util:key1search(ConfigList, port, 80),
 
115
            Addr = httpd_util:key1search(ConfigList, bind_address),
 
116
            {ok, httpd_child_spec(ConfigFile, Addr, Port, Verbosity)};
 
117
        Error ->
 
118
            Error
 
119
    end.
 
120
 
 
121
 
 
122
httpd_child_spec(ConfigFile, Addr, Port, Verbosity) ->
 
123
    {{httpd_sup, Addr, Port},{httpd_sup, start_link,[ConfigFile, Verbosity]},
 
124
     permanent, 20000, supervisor,
 
125
     [ftp,
 
126
      httpd,
 
127
      httpd_conf,
 
128
      httpd_example,
 
129
      httpd_manager,
 
130
      httpd_misc_sup,
 
131
      httpd_listener,
 
132
      httpd_parse,
 
133
      httpd_request,
 
134
      httpd_response,
 
135
      httpd_socket,
 
136
      httpd_sup,
 
137
      httpd_util,
 
138
      httpd_verbosity,
 
139
      inets_sup,
 
140
      mod_actions,
 
141
      mod_alias,
 
142
      mod_auth,
 
143
      mod_cgi,
 
144
      mod_dir,
 
145
      mod_disk_log,
 
146
      mod_esi,
 
147
      mod_get,
 
148
      mod_head,
 
149
      mod_include,
 
150
      mod_log,
 
151
      mod_auth_mnesia,
 
152
      mod_auth_plain,
 
153
      mod_auth_dets,
 
154
      mod_security]}.
 
155
 
 
156
 
 
157
error_msg(F, A) ->
 
158
    error_logger:error_msg(F ++ "~n", A).