Erlang:级联主管?
是否可以在应用程序内级联监管者?
例如,主管 sup1
生成一个子进程,该子进程创建了主管 sup2
?
Is it possible to cascade supervisors inside an application?
E.g. supervisor sup1
spawning a child process which creates a supervisor sup2
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能想将孩子添加为主管。
它是主管子级的子规范中的条目。子级的“type”可以设置为“supervisor”:
http:// /www.erlang.org/doc/design_principles/sup_princ.html#spec
也许你也可以通过孩子自己启动一个主管来做到这一点,但它至少不太优雅,而且你在做什么不太明显。
哈特哈,
h.
You probably want to add the child as supervisor.
It is an entry in the childspec of a child of a supervisor. The "type" of the child can be set to "supervisor":
http://www.erlang.org/doc/design_principles/sup_princ.html#spec
Probably you can do it via the child starting a supervisor itself too but it is at least less elegant and it is less evident what you are doing.
HTH,
h.
是的,您可以简单地将主管添加为主管的子级。或者混合搭配。我通常会做这样的事情:(
在我的顶级主管中)
然后像 emx_sup_data (行为主管)这样的东西包含:
以及像 emx_nodestate (行为 gen_server) 这样的东西
就像一个梦想......!
Yes, you can simply add supervisors as children of a supervisor. Or mix and match. I do something like this usually:
(in my top level supervisor)
And then something like emx_sup_data (behaviour supervisor) contains:
and something like emx_nodestate (behaviour gen_server)
Works like a dream...!
要了解其他人如何构建他们的应用程序,为什么不启动 shell 并运行工具栏:
这为您提供了主管层次结构的图形视图。快速浏览一下内核管理树,或者 mnesia 或 yaws,将向您展示“正常”管理树的样子。
您编写一个由应用程序主管监督的子系统应用程序。每个子系统可以是子系统主管下的许多子子系统(继续以递归功能方式应用模式,直到用尽粒度......)
To see how other folks structure their apps why dont you fire up a shell and run the toolbar:
That gives you a graphical view of a supervisor heirarchy. A quick look at the kernel supervisor tree, or mnesia or yaws, will show you what a 'normal' supervisor tree looks like.
You compose an application of sub-systems supervised by an application supervisor. Each sub-system can be many sub-sub-systems under the sub-system supervisor (continue applying pattern in recursive functional manner until you run out of granularity...)