[erlang-questions] catch supervisor failure

Anton Lebedevich mabrek@REDACTED
Sat Aug 27 10:22:09 CEST 2011


On 08/25/2011 10:56 PM, Max Lapshin wrote:
> I need to fetch url once a minute. It is ok for remote server to fail
> to reply with this url several times, so I want to use supervisor
> mechanism for it:
> 
> set 60 restarts in 5 seconds as a limit and if supervisor fails, it
> should be stopped for some time. After 10 minutes it should be
> restarted.
> 
> Question is: should I use supervisors for this mechanism or I need to
> write my own failure tracker?

Take a look at supervisor2 from rabbitmq-server, it seems that they
implemented desired behaviour:

%% 3) child specifications can contain, as the restart type, a tuple
%%    {permanent, Delay} | {transient, Delay} where Delay >= 0. The
%%    delay, in seconds, indicates what should happen if a child, upon
%%    being restarted, exceeds the MaxT and MaxR parameters. Thus, if
%%    a child exits, it is restarted as normal. If it exits
%%    sufficiently quickly and often to exceed the boundaries set by
%%    the MaxT and MaxR parameters, and a Delay is specified, then
%%    rather than stopping the supervisor, the supervisor instead
%%    continues and tries to start up the child again, Delay seconds
%%    later.

Regards,
Anton Lebedevich.



More information about the erlang-questions mailing list