Added _working_ supervisor behaviour

This commit is contained in:
Jonatan Pålsson 2011-02-01 15:04:15 +01:00
parent 30cebd1c0d
commit 72e411aee9
2 changed files with 17 additions and 8 deletions

View file

@ -2,19 +2,28 @@
-behaviour(supervisor).
%% API
-export([start_link/0]).
-export([start_link/1]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
start_link(Port) ->
supervisor:start_link({local, ?SERVER}, ?MODULE, [Port]).
init([]) ->
Server = {ggs_server, {ggs_server, start_link, []},
permanent, 2000, worker, [ggs_server]},
init([Port]) ->
Server = {ggs_server,
{ggs_server, start_link, [Port]},
permanent,
2000,
worker,
[ggs_server]
},
Children = [Server],
RestartStrategy = {one_for_one, 0, 1},
RestartStrategy = { one_for_one, % Restart only crashing child
10, % Allow ten crashes per..
1 % 1 second, then crash supervisor.
},
{ok, {RestartStrategy, Children}}.