aboutsummaryrefslogtreecommitdiff
path: root/server/src/jchat_sup.erl
blob: cbb61ba42731ae500b6e2be91f3ca3ffd05f4b67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-module(jchat_sup).
-behaviour(supervisor).

-export([start_link/0, init/1]).

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init([]) ->
    % Initialize database
    jchat_db:init(),
    
    % Child specifications
    Children = [
        % HTTP server
        #{
            id => jchat_http,
            start => {jchat_http, start_link, []},
            restart => permanent,
            shutdown => 5000,
            type => worker,
            modules => [jchat_http]
        },
        % Push notification manager
        #{
            id => jchat_push,
            start => {jchat_push, start_link, []},
            restart => permanent,
            shutdown => 5000,
            type => worker,
            modules => [jchat_push]
        },
        % Presence manager
        #{
            id => jchat_presence,
            start => {jchat_presence, start_link, []},
            restart => permanent,
            shutdown => 5000,
            type => worker,
            modules => [jchat_presence]
        }
    ],
    
    SupFlags = #{
        strategy => one_for_one,
        intensity => 10,
        period => 60
    },
    
    {ok, {SupFlags, Children}}.