-
Notifications
You must be signed in to change notification settings - Fork 19
/
shadowsocks_sup.erl
49 lines (37 loc) · 1.46 KB
/
shadowsocks_sup.erl
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
%%%-------------------------------------------------------------------
%%% @author Yongke <[email protected]>
%%% @copyright (C) 2013, Yongke
%%% @doc
%%% Supervisor
%%% @end
%%%-------------------------------------------------------------------
-module(shadowsocks_sup).
-behaviour(supervisor).
%% API
-export([start_link/1]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%%===================================================================
%%% API functions
%%%===================================================================
start_link([_, ListeningPort | _] = Args) ->
supervisor:start_link({local, ?SERVER}, ?MODULE,
[ListeningPort, shadowsocks_fsm, Args]).
%%%===================================================================
%%% Supervisor callbacks
%%%===================================================================
init([Port, Module, Args]) ->
RestartStrategy = one_for_one,
MaxRestarts = 1000,
MaxSecondsBetweenRestarts = 3600,
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
Restart = permanent,
Shutdown = 2000,
Type = worker,
Child = {tcp_server_sup, {tcp_listener,start_link,[Port,Module,Args]},
Restart, Shutdown, Type, [tcp_listener]},
{ok, {SupFlags, [Child]}}.
%%%===================================================================
%%% Internal functions
%%%===================================================================