Skip to content

Commit

Permalink
Make default restart intensity values configurable
Browse files Browse the repository at this point in the history
Add two application parameters, `max_restart` and
`max_seconds_between_restarts`, to allow an external application
to configure these values. See README.md for details.
  • Loading branch information
catamorphism committed Nov 3, 2014
1 parent bb3bd32 commit b394ad3
Show file tree
Hide file tree
Showing 2 changed files with 15 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
7 changes: 4 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 = application:get_env(episcina, max_restarts, 1000),
MaxT = application:get_env(episcina, max_seconds_between_restarts, 3600),

SupFlags = {RestartStrategy, MaxR, MaxT},

Restart = permanent,
Shutdown = 2000,
Expand Down

0 comments on commit b394ad3

Please sign in to comment.