server is up?

Is there a way to tell a gen_server: "supervisor has initialised all gen_servers, now you can send then messages"? I have a worker gen_server whose job is to set up states of other gen_servers in his supervision tree. If I just start sending messages in init function of my configuration server, sometimes it gets {noproc, _}. I suppose that means that config server was to fast: he se

服务器已启动?

有没有办法告诉gen_server:“supervisor已经初始化所有的gen_servers,现在你可以发送消息”? 我有一个工人gen_server,其工作是在他的监督树中设置其他gen_servers的状态。 如果我刚开始在配置服务器的init函数中发送消息,有时会得到{noproc,_}。 我想这意味着配置服务器要快:他在主管有足够的时间启动所有工作人员之前发送了消息。 我通过将timer:sleep(500)放在config_server:init()中来解决这个问题,它可以确

What's the best way to run a gen

I'm building a monitoring tool in Erlang. When run on a cluster, it should run a set of data collection functions on all nodes and record that data using RRD on a single "recorder" node. The current version has a supervisor running on the master node ( rolf_node_sup ) which attempts to run a 2nd supervisor on each node in the cluster ( rolf_service_sup ). Each of the on-node sup

运行gen的最佳方式是什么?

我正在Erlang建立一个监控工具。 在群集上运行时,它应该在所有节点上运行一组数据收集功能,并在单个“记录器”节点上使用RRD记录该数据。 当前版本在主节点( rolf_node_sup )上运行一个管理程序,该管理程序试图在集群中的每个节点上运行第二个管理程序( rolf_service_sup )。 然后,每个节点监控程序都应该启动并监控将消息发送回主节点上的gen_server( rolf_recorder )的一堆进程。 这只适用于本地。 没有管理员

Using more than one erlang behaviour

I have an erlang gen_fsm process that talks to a remote server via tcp using erlang's built-in gen_tcp. I would like to make this a web-socket client. Upon some investigation, I got this erlang websocket client library Erlang Websocket client. looking at some examples, it looks like I have to use the -behaviour(websocket_client_handler). Basically, I do this in my start_link start_l

使用多个erlang行为

我有一个erlang gen_fsm进程,使用erlang的内置gen_tcp通过tcp与远程服务器通信。 我想使这个网络套接字客户端。 经过一番调查,我得到了这个erlang websocket客户端库Erlang Websocket客户端。 看一些例子,它看起来像我必须使用 -behaviour(websocket_client_handler)。 基本上,我在我的start_link中这样做 start_link(UserID) -> gen_fsm:start_link(?MODULE, [UserID], []). 但是,其他行为期望init和不

Starting and Terminating child of simple

I have a simple application target_interceptor that upon receiving register and unregister messages, starts or terminates workers under simple_one_for_one rpc_server_supervisor . The code of supervisor rpc_server_supervisor : init([]) -> MaxRestart = 5, MaxTime = 3600, {ok, {{simple_one_for_one, MaxRestart, MaxTime}, [{rbmq_rpc_server, {rbmq_rpc_serv

开始和终止简单的孩子

我有一个简单的应用程序target_interceptor ,它在接收到注册和取消注册消息后,在simple_one_for_one rpc_server_supervisor下启动或终止工作。 主管rpc_server_supervisor的代码: init([]) -> MaxRestart = 5, MaxTime = 3600, {ok, {{simple_one_for_one, MaxRestart, MaxTime}, [{rbmq_rpc_server, {rbmq_rpc_server, start_link, []}, temporary,

Erlang spawn a supervisor with a parameter

I have a server which is created like this : gateway.erl (supervisor of the supervisor) -> gateway_sup.erl (supervisor of gen_servers) -> gateway_serv.erl (Where every client are handled). This is pretty basic as I saw over the internet, most people are doing like this. The Listen Socket is created on the gateway_sup.erl, and I would like to listen over multiple sockets in case some c

Erlang用一个参数产生一个主管

我有一个这样创建的服务器: gateway.erl(监督者的监督者) - > gateway_sup.erl(gen_servers的监督者) - > gateway_serv.erl(每个客户端都被处理)。 这是非常基本的,因为我通过互联网看到,大多数人都是这样做的。 监听套接字在gateway_sup.erl上创建,并且我想在一些客户端端口限制的情况下监听多个套接字。 所以这是我的代码到目前为止。 gateway.erl -export([start_link/0, init/1, startWithPort/1]

What is the point of having temporary children for Erlang supervisors?

Supervisors are there to restart processes that fail. Temporary processes are ones that should never be restarted. So, why bother having this type of child for a supervisor? Is it mainly so they can be terminated as part of a one_for_all strategy, or when the application is terminated? There are several problems with the view that supervisors only exist to restart jobs. Here are a few of th

为Erlang主管提供临时子女有什么意义?

主管在那里重新启动失败的进程。 临时进程是不应该重新启动的进程。 那么,为什么还要让这种类型的孩子担任主管? 这主要是因为它们可以作为one_for_all策略的一部分终止,或者当应用程序终止时? 主管只存在重新启动作业的观点存在几个问题。 这里有几个: “临时”的含义是模糊的。 重新启动一个未完成的工作(可能是资源限制或其他外部原因),并让一个进程到期并完成其工作是两件不同的事情。 Supervisors提供了一

Erlang supervisor: how to check if all the workers have replied

I have a supervisor with N worker processes. As usual the supervisor can send a message to a worker process and there is a handle_cast that sends a reply from a worker to the supervisor. How can I check that exactly all N workers have replied to the supervisor? Is it possible to implement this with any kind of event handling - ie to tell the supervisor "Ok, everyone has replied" and

Erlang主管:如何检查所有工作人员是否已回复

我有一个有N个工作流程的主管。 像往常一样,主管可以向工作进程发送消息,并且有一个handle_cast将工作人员的回复发送给主管。 我如何检查确切地说,所有N员工都已回复给主管? 是否可以通过任何形式的事件处理来实现 - 即告诉主管“好的,每个人都已回复”,并且不要让主管每秒在某种ETS中检查“全部N个进程已回复”状态儿童注册表表? 如果你正在谈论一位OTP supervisor ,不,你不能从它发送消息给工作人员。 主管的行为

Automatically restarting Erlang applications

I recently ran into a bug where an entire Erlang application died, yielding a log message that looked like this: =INFO REPORT==== 11-Jun-2010::11:07:25 === application: myapp exited: shutdown type: temporary I have no idea what triggered this shutdown, but the real problem I have is that it didn't restart itself. Instead, the now-empty Erlang VM just sat there doing nothing.

自动重启Erlang应用程序

我最近遇到了一个错误,整个Erlang应用程序死了,产生一个如下所示的日志消息: =INFO REPORT==== 11-Jun-2010::11:07:25 === application: myapp exited: shutdown type: temporary 我不知道是什么引发了这种关机,但我所遇到的真正问题是它没有自行重启。 相反,现在空的Erlang VM只是坐在那里无所事事。 现在,根据我所做的研究,看起来您可以提供其他“开始类型”:“短暂”和“永久”。 如果我在一个应用程

Supervisor does not restart on econnrefused (thrown in init/1)

I have a gen_server's init function I connect to rabbitmq. When all is good then it works perfectly fine however when connecting to rabbitmq fails and I call exit the process is not restarted. I would like to make supervisor restart this process after me calling exit . Conceptually my init function is like this: init(_Args) -> process_flag(trap_exit, true), case connect() of

Supervisor不会在econnrefused(在init / 1中抛出)

我有一个gen_server的init函数,我连接到rabbitmq。 当一切都很好时,它可以很好地工作,但是当连接到rabbitmq失败时,我调用exit进程不会重新启动。 我想在主管exit后让主管重新启动这个过程。 从概念上讲,我的init函数是这样的: init(_Args) -> process_flag(trap_exit, true), case connect() of {error, econnrefused} -> timer:sleep(1000), exit(econnrefused); {ok, Co

erlang otp application is not restarted when it crashes

I've been reading the book Erlang and OTP In Action and trying the source code in chapter 4 which builds an OTP application. There is a gen_server that has these call back methods (full source): %%%=================================================================== %%% gen_server callbacks %%%=================================================================== init([Port]) -> {ok, L

erlang otp应用程序在崩溃时不会重新启动

我一直在阅读Erlang和OTP In Action这本书,并在第4章中尝试构建OTP应用程序的源代码。 有一个gen_server具有这些回调方法(完整源代码): %%%=================================================================== %%% gen_server callbacks %%%=================================================================== init([Port]) -> {ok, LSock} = gen_tcp:listen(Port, [{active, true}]), {ok, #state{port