Skip to content

Commit

Permalink
Merge pull request #8 from catamorphism/config_restart_intensity
Browse files Browse the repository at this point in the history
Make default restart intensity values configurable
  • Loading branch information
tsloughter committed Nov 3, 2014
2 parents bb3bd32 + e6220d1 commit cbe39c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ connect. There are several parameters that are required.
name of the function and any arguments needed to be passed to that
function. There is an example below.

episcina also has two optional parameters:

* `max_restarts`: the number of restarts that are allowed
to occur within `max_seconds_between_restarts` seconds. (Default: 1000)
* `max_seconds_between_restarts`: If more than `max_restarts` restarts
occur within `max_seconds_between_restarts` seconds, the episcina supervisor
will terminate all its child processes, then itself. (Default: 3600)

#### sys.config file example:

{episcina, [{pools, [{db1,
{episcina, [{max_restarts, 2000},
{max_seconds_between_restarts, 7200},
{pools, [{db1,
[{size, 10},
{timeout, 10000},
{connect_provider, {pgsql, connect,
Expand Down
15 changes: 12 additions & 3 deletions src/epna_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ start_pool(Name, Size, Timeout, ConnectFun, CloseFun) ->
%%@private
init([]) ->
RestartStrategy = simple_one_for_one,
MaxRestarts = 1000,
MaxSecondsBetweenRestarts = 3600,

SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
MaxR = get_env(max_restarts, 1000),
MaxT = get_env(max_seconds_between_restarts, 3600),

SupFlags = {RestartStrategy, MaxR, MaxT},

Restart = permanent,
Shutdown = 2000,
Expand All @@ -52,3 +53,11 @@ init([]) ->
%%%===================================================================
%%% Internal functions
%%%===================================================================

get_env(Key, Default) ->
case application:get_env(episcina, Key) of
undefined ->
Default;
{ok, Value} ->
Value
end.

0 comments on commit cbe39c9

Please sign in to comment.