erlang-supervisor

Erlang simple_one_for_one supervisor does not restart child

有些话、适合烂在心里 提交于 2020-06-18 12:35:13
问题 I have a test module and a simple_one_for_one supervisor. test.erl -module(test). -export([ run/1, do_job/1 ]). run(Fun) -> test_sup:start_child([Fun]). do_job(Fun) -> Pid = spawn(Fun), io:format("started ~p~n", [Pid]), {ok, Pid}. test_sup.erl -module(test_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). -export([start_child/1]). start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). init(_Args) -> SupFlags = #{strategy => simple_one_for_one, intensity

Why my supervisor terminating?

倾然丶 夕夏残阳落幕 提交于 2020-04-29 09:17:25
问题 I'm very new to OTP, I'm trying to create simple example to understand supervisor behaviour: Here is simple increment server -module( inc_serv ). -behaviour( gen_server ). -export( [ start/0, inc/1, stop/0 ] ). -export( [ init/1, handle_call/3, terminate/2 ] ). start() -> gen_server:start_link( { local, ?MODULE }, ?MODULE, no_args, [] ). stop() -> gen_server:call( ?MODULE, stop ). inc( Num ) -> gen_server:call( ?MODULE, { num, Num } ). init( no_args ) -> io:format( "~p~n", [ "Increment server

Why my supervisor terminating?

空扰寡人 提交于 2020-04-29 09:17:21
问题 I'm very new to OTP, I'm trying to create simple example to understand supervisor behaviour: Here is simple increment server -module( inc_serv ). -behaviour( gen_server ). -export( [ start/0, inc/1, stop/0 ] ). -export( [ init/1, handle_call/3, terminate/2 ] ). start() -> gen_server:start_link( { local, ?MODULE }, ?MODULE, no_args, [] ). stop() -> gen_server:call( ?MODULE, stop ). inc( Num ) -> gen_server:call( ?MODULE, { num, Num } ). init( no_args ) -> io:format( "~p~n", [ "Increment server

Erlang Supervisor Strategy For Restarting Connections to Downed Hosts

一笑奈何 提交于 2020-01-22 19:48:26
问题 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. My inclination is to put a sleep into the reboot of the AMQP code. Wouldn't that 'hack' essentially circumvent the

Does supervisor block calls while restarting children?

百般思念 提交于 2020-01-04 05:40:40
问题 I'm trying to understand what's happening here: I have a supervisor that is cyclically restarting one client without triggering the MaxR, MaxT mechanism. The client just crashes slowly enough never to trigger the rate limitation. There would have been another mechanism that uses supervisor:which_children/1 and delete_child/2, start_child/2 to adapt the set of children to reality (its scanning for USB devices trying to have one supervisor child per device found). This would normally behave

How can a supervisor that reached_max_restart_intensity only delete the offending child?

流过昼夜 提交于 2019-12-24 02:59:13
问题 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 supervisor exception on starting worker

隐身守侯 提交于 2019-12-12 02:05:49
问题 I'm playing with code for supervisor trees taken from http://learnyousomeerlang.com/building-applications-with-otp but I get a noproc exception that I can't figure out when I try to get a supervisor to start the child process. This is my shell interaction: 1> application:start(test). root supervisor init ok 2> test_sup:start_service(service_sup,{service_worker, start_link,[]}). {ok,<0.39.0>} worker supervisor initialise (M: service_worker,F: start_link,A: []) 3> test_app:run(service_worker,[]

Why do we need simple_one_for_one?

巧了我就是萌 提交于 2019-12-11 10:04:18
问题 Somebody told me that simple_one_for_one is very useful for chat applications, because each chat client is a server process (gen_server). Is this right? And I wonder why do we need it? Why not create only one center server (gen_server) to handle all chat client communication? Because maybe the number of chat clients is very large so only one server couldn't handle fast, make the system slow down? I think maybe creating too many servers like simple_one_for_one may take too much system resource