Erlang supervisor does not restart child

I'm trying to learn about erlang supervisors. I have a simple printer process that prints hello every 3 seconds. I also have a supervisor that must restart the printer process if any exception occurs. Here is my code: test.erl: -module(test). -export([start_link/0]). start_link() -> io:format("started~n"), Pid = spawn_link(fun() -> loop() end), {ok, Pid}. lo

Erlang主管不重新启动孩子

我正在尝试了解erlang主管。 我有一个简单的printer process ,每3秒打印一次hello。 如果发生任何异常,我也有一个主管必须重新启动printer process 。 这是我的代码: test.erl: -module(test). -export([start_link/0]). start_link() -> io:format("started~n"), Pid = spawn_link(fun() -> loop() end), {ok, Pid}. loop() -> timer:sleep(3000), io:format("hello~n"),

Erlang supervisor dynamic change to restart intensity

My question is, can one modify the restart intensity thresholds of an already running supervisor, apart from in a release upgrade scenario, and if so, how? It's never come up before, but running a supervisor with initially no children, so that another process starts children by way of supervisor:start_child/2, so my sup init/1 being like this: init([]) -> RestartSt = {simple_one_for

Erlang管理员动态更改重启强度

我的问题是,除了发布升级方案之外,是否可以修改已运行的主管的重新启动强度阈值,如果是这样,如何呢? 这是从来没有出现过,但运行一个监督最初没有孩子,所以另一个进程启动孩子通过主管的方式:start_child / 2,所以我的sup init / 1是这样的: init([]) -> RestartSt = {simple_one_for_one, 10, 10}, ChSpec = [foo, {foo,start_link,[]}, transient, 1000, worker, [foo]}], {ok, {RestartSt, ChSpec}

server by supervisor in Erlang

In Erlang, I have a supervisor (my_sup) module to starts and monitor the gen_server process (my_gen). When the my_gen is modified, compiled and loaded, I need to restart the application. Is there any better way to kill all the process (gen_server) by the supervisor (my_sup) and restart the process (gen_server) again? To fix this is to stop the child and restart it. Stop and reload the chil

服务器由Erlang的主管完成

在Erlang中,我有一个主管(my_sup)模块来启动和监视gen_server进程(my_gen)。 当my_gen被修改,编译和加载时,我需要重新启动应用程序。 有没有更好的方法来由管理程序(my_sup)终止所有进程(gen_server),并重新启动进程(gen_server)? 解决这个问题是停止孩子并重新启动它。 停止并重新加载孩子 restart_pool() -> supervisor:terminate_child(?SEVER, ?WORKER), supervisor:restart_child(?SERVER

Erlang Supervisor fail to start

the supervisor seems to fail silently starting child... Here's the supervisor -behaviour(supervisor). -export([start_socket/0, init/1, start_link/1]). -define(SSL_OPTIONS, [{active, once}, {backlog, 128}, {reuseaddr, true}, {packet, 0}, {cacertfile, "./ssl_key/server/gd_bundle.crt"},

Erlang Supervisor无法启动

主管似乎默默无闻地开始了孩子...... 这是主管 -behaviour(supervisor). -export([start_socket/0, init/1, start_link/1]). -define(SSL_OPTIONS, [{active, once}, {backlog, 128}, {reuseaddr, true}, {packet, 0}, {cacertfile, "./ssl_key/server/gd_bundle.crt"}, {certfile, "./ssl_key/server/cert.

Erlang supervisor restart interval

I have a supervisor with one_for_one restart strategy. Is it possible to set some time interval between child process restarting? Fe remote db crushed and I want to wait 10 seconds between restore connection attempt. Actually, you could let the supervisor to immediately restart its children and implement what is called lazy initialization: The supervisor (re)starts (immediately) the child

Erlang管理员重启间隔

我有一个主管采用one_for_one重启策略。 是否可以设置子进程重启之间的一段时间间隔? Fe远程数据库崩溃了,我想在恢复连接尝试之间等待10秒钟。 实际上,您可以让主管立即重新启动其子项并实施所谓的延迟初始化: 主管(重新)启动(立即)孩子(比如gen_server) gen_server在其init函数中返回0超时 在handle_info中,您会主动等待(您的10秒钟)以确保数据库已正确初始化 这样,您可以确保在正确初始化DB之后处

erlang supervisor best way to handle ibrowse:send

new to Erlang and just having a bit of trouble getting my head around the new paradigm! OK, so I have this internal function within an OTP gen_server: my_func() -> Result = ibrowse:send_req(?ROOTPAGE,[{"User-Agent",?USERAGENT}],get), case Result of {ok, "200", _, Xml} -> %<<do some stuff that won't interest you>> ,ok; {error,{conn_failed,{error,nxdomain}}} -> <<w

erlang主管处理ibrowse的最佳方式:发送

对Erlang来说是新的东西,并且让我的头脑在这个新范例中遇到一些麻烦! 好的,所以我在OTP gen_server中有这个内部函数: my_func() -> Result = ibrowse:send_req(?ROOTPAGE,[{"User-Agent",?USERAGENT}],get), case Result of {ok, "200", _, Xml} -> %<<do some stuff that won't interest you>> ,ok; {error,{conn_failed,{error,nxdomain}}} -> <<what the heck do I do here?>> en

erlang supervisor restart strategy

I would like to start several processes as children of a given supervisor. The restart strategy is one_for_one For my needs, every process which terminates should be restarted after a given amount of time (eg 20 seconds). How can this be done? Maybe with a delay in the init or in the terminate functions in combination with: Shutdown = brutal_kill | integer() >=0 | infinity Is there a bet

erlang管理员重启策略

我想开始几个过程作为给定主管的孩子。 重启策略是one_for_one对于我的需求,每一个终止的进程应该在给定的时间量(例如20秒)之后重新启动。 如何才能做到这一点? 也许延迟init或终止函数结合使用: Shutdown = brutal_kill | integer() >=0 | infinity 有没有更好的方法来实现这一目标? 不要为此使用init/1 。 当init运行时,主管被阻塞。 最好立即启动这个过程,但是只有等待20秒后才让它自己注册。 您可以在

Erlang OTP supervisor

I'm working on Exercise 12-2 from the book Erlang Programming. I have a module db_server_otp that implements an OTP gen_server behavior. As a stand-alone module, I have tested it and it works as expected. I now have to add a supervisor for it. Based on the example in the chapter, I created a module db_server_sup as follows: -module(db_server_sup). -export([start/0,init/1]). -behavior(sup

Erlang OTP主管

我正在从Erlang编程的书中练习练习12-2。 我有一个实现OTP gen_server行为的模块db_server_otp 。 作为一个独立的模块,我已经测试过它,它按预期工作。 我现在必须为它添加一个主管。 根据本章中的示例,我创建了一个模块db_server_sup ,如下所示: -module(db_server_sup). -export([start/0,init/1]). -behavior(supervisor). start() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). init(_Argumen

erlang OTP Supervisor crashing

I'm working through the Erlang documentation, trying to understand the basics of setting up an OTP gen_server and supervisor. Whenever my gen_server crashes, my supervisor crashes as well. In fact, whenever I have an error on the command line, my supervisor crashes. I expect the gen_server to be restarted when it crashes. I expect command line errors to have no bearing whatsoever on my s

erlang OTP主管崩溃

我正在通过Erlang文档,试图了解设置OTP gen_server和supervisor的基础知识。 每当我的gen_server崩溃时,我的主管也崩溃了。 事实上,无论何时我在命令行中遇到错误,我的主管崩溃。 我期望gen_server在崩溃时重新启动。 我希望命令行错误对我的服务器组件没有任何影响。 我的主管不应该崩溃。 我正在使用的代码是一个基本的“回应服务器”,可以回复您发送的任何内容,并且管理员最多可以每分钟重复5次echo_server(one_

Erlang Supervisor Strategy For Restarting Connections to Downed Hosts

I'm using erlang as a bridge between services and I was wondering what advice people had for handling downed connections? I'm taking input from local files and piping them out to AMQP and it's conceivable that the AMQP broker could go down. For that case I would want to keep retrying to connect to the AMQP server but I don't want to peg the CPU with those connections attempts.

Erlang管理员重新启动与下降主机连接的策略

我使用erlang作为服务之间的桥梁,我想知道人们在处理连接断开时有什么建议? 我从本地文件接收输入并将它们传送到AMQP,并且可以想象AMQP代理可能会关闭。 对于这种情况,我想继续重试连接到AMQP服务器,但我不想用这些连接尝试挂钩CPU。 我的意图是让AMQP代码重新启动。 这种“黑客”是不是基本上绕过了快速失败并让erlang处理它的目的? 更一般地说,erlang监督者行为是否应该用于处理连接断开? 我认为编写自己的语义