问题描述
我有一个 one_for_one
主管处理类似且完全独立的孩子。
当有问题一个孩子,反复崩溃和触发:
=监督报告==== 2011年3月30日:: 13:10: 42 ===
主管:{local,gateway_sup}
上下文:关闭
原因:达到_max_restart_intensity
罪犯:[{pid,< 0.76.0>},...
关闭自己,并终止所有无辜的孩子,否则会继续运行。 p>
如何从标准的Erlang主管中建立一个监督树,只能停止重新启动一个违规的孩子,并离开别人?
我正在想一个额外的主管,只有一个孩子,但这似乎对我来说很重。
任何其他方法来处理这个? p>
我th墨水最好的解决办法就是要有两层监督。
一个主管为每个 gen_server $ c启动一个主管+进程对$ c>你想要运行。该主管配置了
one_for_one
策略,临时
孩子。
在这位主管下运行的每个主管都将正确配置 MaxR
和 MaxT
值,这将触发该事件的崩溃一旦小孩不当行为,主管。
当下级主管崩溃时,顶级主管不在乎。
当一个孩子(总堆大小)启动时,主管消耗233字节,因此内存消耗不应该是一个问题。
监督树应该看起来像:
supervisor_top
|
|
+ ------------------------ + ----- ...
| |
supervisor_1 supervisor_2
重新启动临时重新启动
| |
gen_server_1 gen_server_2
重启瞬态重启瞬态
I have a one_for_one
supervisor that handles similar and totally independent children.
When there is a problem with one child, repeatedly crashing and triggering:
=SUPERVISOR REPORT==== 30-Mar-2011::13:10:42 ===
Supervisor: {local,gateway_sup}
Context: shutdown
Reason: reached_max_restart_intensity
Offender: [{pid,<0.76.0>}, ...
shutting itself down and also terminating all the innocent children that would just continue to run fine otherwise.
How can I build a supervision tree out of standard Erlang supervisors that only stops to restart the one offending child and leaves the others alone?
I was thinking about having a extra supervisor with just one single child but this seems to heavyweight to me.
Any other ways to handle this?
I think the best solution would be to have two layers of supervision.
One supervisor which starts a supervisor + process pair for each gen_server
you want running. This supervisor is configured with one_for_one
strategy and temporary
children.
Each supervisor running under this supervisor would have correctly configured MaxR
and MaxT
values, that will trigger a crash of that supervisor once the child misbehaves.
When the lower level supervisor crashes, the top level supervisor "just doesn't care".
A supervisor consumes 233 bytes when started with one child (total heap size) so memory consumption should not be an issue.
The supervision tree should look like:
supervisor_top
|
|
+------------------------+----- ...
| |
supervisor_1 supervisor_2
restart temporary restart temporary
| |
gen_server_1 gen_server_2
restart transient restart transient
这篇关于达到_max_restart_intensity的主管如何才能删除有罪的孩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!