简体   繁体   English

Erlang:谁监督主管?

[英]Erlang: Who supervises the supervisor?

In all Erlang supervisor examples I have seen yet, there usually is a "master" supervisor who supervises the whole tree (or at least is the root node in the supervisor tree). 在我所见过的所有Erlang主管示例中,通常都有一个“主”主管监督整个树(或者至少是主管树中的根节点)。 What if the "master"-supervisor breaks? 如果“主人” - 监督员破裂怎么办? How should the "master"-supervisor be supervised?? 如何监督“主人”监督? any typical pattern? 任何典型的模式?

The top supervisor is started in your application start/2 callback using start_link, this means that it links with the application process. 顶级管理程序使用start_link在您的应用程序启动/ 2回调中启动,这意味着它与应用程序进程链接。 If the application process receives an exit signal from the top supervisor dying it does one of two things: 如果应用程序进程收到顶级主管死亡的退出信号,它会执行以下两项操作之一:

  1. If the application is started as an permanent application the entire node i terminated (and maybe restarted using HEART). 如果应用程序作为永久应用程序启动,则整个节点终止(并且可能使用HEART重新启动)。

  2. If the application is started as temporary the application stops running, no restart attempts will be made. 如果应用程序作为临时启动应用程序停止运行,则不会尝试重新启动。

Typically Supervisor is set to "only" supervise other processes. 通常,Supervisor设置为“仅”监督其他进程。 Which mens there is no user written code which is executed by Supervisor - so it very unlikely to crash. 哪个男士没有用户编写的代码由Supervisor执行 - 所以它不太可能崩溃。

Of course, this cannot be enforced ... So typical pattern is to not have any application specific logic in Supervisor ... It should only Supervise - and do nothing else. 当然,这不能强制执行......所以典型的模式是在Supervisor中没有任何特定于应用程序的逻辑......它应该只监督 - 而不做任何其他事情。

Good question. 好问题。 I have to concur that all of the examples and tutorials mostly ignore the issue - even if occasionally someone mentions the issue (without providing an example solution): 我必须同意所有示例和教程大多忽略了这个问题 - 即使偶尔有人提到问题(没有提供示例解决方案):

If you want reliability, use at least two computers, and then make them supervise each other. 如果您需要可靠性,请至少使用两台计算机,然后让它们相互监督。 How to actually implement that with OTP is (with the current state of documentation and tutorials), however, appears to be somewhere between well hidden and secret. 然而,如何使用OTP实际实现(使用文档和教程的当前状态)似乎介于隐藏和秘密之间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM