~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/inets/src/inets_app/inets_sup.erl

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

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$
 
17
%%
 
18
%%----------------------------------------------------------------------
 
19
%% Purpose: The top supervisor for the inets application
 
20
%%----------------------------------------------------------------------
 
21
 
 
22
-module(inets_sup).
 
23
 
 
24
-behaviour(supervisor).
 
25
 
 
26
-export([init/1]).
 
27
 
 
28
%%%=========================================================================
 
29
%%%  Supervisor callback
 
30
%%%=========================================================================
 
31
init([]) ->
 
32
    SupFlags = {one_for_one, 10, 3600},
 
33
    Children = children(), 
 
34
    {ok, {SupFlags, Children}}.
 
35
 
 
36
%%%=========================================================================
 
37
%%%  Internal functions
 
38
%%%=========================================================================
 
39
get_services() ->
 
40
    case (catch application:get_env(inets, services)) of
 
41
        {ok, Services} ->
 
42
            Services;
 
43
        _ ->
 
44
            []
 
45
    end.
 
46
 
 
47
children() ->
 
48
    Services = get_services(),
 
49
    HttpdServices = [Service || Service <- Services, is_httpd(Service)],
 
50
    HttpcServices =  [Service || Service <- Services, is_httpc(Service)],
 
51
    TftpdServices =  [Service || Service <- Services, is_tftpd(Service)],
 
52
    [ftp_child_spec(), httpc_child_spec(HttpcServices), 
 
53
     httpd_child_spec(HttpdServices), tftpd_child_spec(TftpdServices)].
 
54
 
 
55
ftp_child_spec() ->
 
56
    Name = ftp_sup,
 
57
    StartFunc = {ftp_sup, start_link, []},
 
58
    Restart = permanent, 
 
59
    Shutdown = infinity,
 
60
    Modules = [ftp_sup],
 
61
    Type = supervisor,
 
62
    {Name, StartFunc, Restart, Shutdown, Type, Modules}.
 
63
 
 
64
httpc_child_spec(HttpcServices) ->
 
65
    Name = httpc_sup,
 
66
    StartFunc = {httpc_sup, start_link, [HttpcServices]},
 
67
    Restart = permanent, 
 
68
    Shutdown = infinity,
 
69
    Modules = [httpc_sup],
 
70
    Type = supervisor,
 
71
    {Name, StartFunc, Restart, Shutdown, Type, Modules}.
 
72
 
 
73
httpd_child_spec(HttpdServices) ->
 
74
    Name = httpd_sup,
 
75
    StartFunc = {httpd_sup, start_link, [HttpdServices]},
 
76
    Restart = permanent, 
 
77
    Shutdown = infinity,
 
78
    Modules = [httpd_sup],
 
79
    Type = supervisor,
 
80
    {Name, StartFunc, Restart, Shutdown, Type, Modules}.
 
81
 
 
82
tftpd_child_spec(TftpServices) ->
 
83
    Name = tftp_sup,
 
84
    StartFunc = {tftp_sup, start_link, [TftpServices]},
 
85
    Restart = permanent, 
 
86
    Shutdown = infinity,
 
87
    Modules = [tftp_sup],
 
88
    Type = supervisor,
 
89
    {Name, StartFunc, Restart, Shutdown, Type, Modules}.
 
90
 
 
91
is_httpd({httpd, _}) ->
 
92
    true;
 
93
is_httpd({httpd, _, _}) ->
 
94
    true;
 
95
is_httpd(_) ->
 
96
    false.
 
97
 
 
98
is_httpc({httpc, _}) ->
 
99
    true;
 
100
is_httpc(_) ->
 
101
    false.
 
102
 
 
103
is_tftpd({tftpd, _}) ->
 
104
    true;
 
105
is_tftpd(_) ->
 
106
    false.