erlang-supervisor

How to keep track of children processes in erlang?

痴心易碎 提交于 2019-12-11 02:26:28
问题 I have a static list of "hosts" with their info, and a dynamic list of "host agents". Each host has one and only one agent for as long as it connects to the server by a TCP connection. As the host may or may not be connected, its agent process may or may not be started. When a TCP packet arrives with the host ID, I need to find out if the "agent" of this host is started or not. Connection is responsible for receive and send data from tcp socket, parse the data to find out which host it should

Cannot spawn an erlang supervisor from the shell

放肆的年华 提交于 2019-12-10 15:49:12
问题 I've implemented a gen_server and supervisor: test_server and test_sup . I want to test them from the shell/CLI. I've written their start_link functions such that their names are registered locally. I've found that I can spawn the test_server from the command line just fine, but a spawned test_sup does not allow me to interact with the server at all. For example, I can spawn a test_server by executing: 1> spawn(test_server, start_link, []). <0.39.0> 2> registered(). [...,test_server,...] I

Erlang: what supervision tree should I end with writing a task scheduler?

巧了我就是萌 提交于 2019-12-08 07:06:55
问题 Mostly in educational purposes I'm trying to write a task (task is an open_port({spawn_executable, Command})) scheduler. I end up with the tree like supervisor | | scheduler receiver gen_event gen_event | supervisor | dispatcher gen_server | supervisor | | | task1 ... taskN In other words: top supervisor starts scheduler and receiver and makes sure they will be alive receiver starts middle supervisor middle supervisor starts dispatcher and makes sure it will be alive dispatcher starts bottom

What's the best way to run a gen_server on all nodes in an Erlang cluster?

廉价感情. 提交于 2019-12-03 09:25:11
问题 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 supervisors should then start and monitor a bunch of processes which send messages back to a gen_server on the master

Erlang: supervisor(3), adding a child process

╄→尐↘猪︶ㄣ 提交于 2019-12-03 07:17:00
问题 Where can I find example on how to add dynamic child processes to an existing supervisor ( simple_one_for_one restart strategy) ? 回答1: I did some research, and below is what I have. First, this is a sample callback module of a supervisor: -module(root_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). start_link() -> {ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, []), {ok, Pid}. init(_Args) -> RestartStrategy = {simple_one_for_one, 10, 60}, ChildSpec =

What's the best way to run a gen_server on all nodes in an Erlang cluster?

夙愿已清 提交于 2019-12-02 23:42:01
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 supervisors should then start and monitor a bunch of processes which send messages back to a gen_server on the master node ( rolf_recorder ). This only works locally. No supervisor is started on any remote node. I use the

Erlang: supervisor(3), adding a child process

我与影子孤独终老i 提交于 2019-12-02 22:05:51
Where can I find example on how to add dynamic child processes to an existing supervisor ( simple_one_for_one restart strategy) ? I did some research, and below is what I have. First, this is a sample callback module of a supervisor: -module(root_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). start_link() -> {ok, Pid} = supervisor:start_link({local, ?MODULE}, ?MODULE, []), {ok, Pid}. init(_Args) -> RestartStrategy = {simple_one_for_one, 10, 60}, ChildSpec = {ch1, {ch1, start_link, []}, permanent, brutal_kill, worker, [ch1]}, Children = [ChildSpec], {ok,

How to find the supervisor of an OTP process?

若如初见. 提交于 2019-12-01 16:51:08
Are there functions which would allow an OTP process to find the pid of its supervisor? The data is hidden in the process dictionary (of any process spawned with proc_lib ) under the entry '$ancestors' : 1> proc_lib:spawn(fun() -> timer:sleep(infinity) end). <0.33.0> 2> i(0,33,0). [{current_function,{timer,sleep,1}}, {initial_call,{proc_lib,init_p,3}}, {status,waiting}, {message_queue_len,0}, {messages,[]}, {links,[]}, {dictionary,[{'$ancestors',[<0.31.0>]}, {'$initial_call',{erl_eval,'-expr/5-fun-1-',0}}]}, {trap_exit,false}, {error_handler,error_handler}, {priority,normal}, {group_leader,<0

How to find the supervisor of an OTP process?

霸气de小男生 提交于 2019-12-01 16:07:57
问题 Are there functions which would allow an OTP process to find the pid of its supervisor? 回答1: The data is hidden in the process dictionary (of any process spawned with proc_lib ) under the entry '$ancestors' : 1> proc_lib:spawn(fun() -> timer:sleep(infinity) end). <0.33.0> 2> i(0,33,0). [{current_function,{timer,sleep,1}}, {initial_call,{proc_lib,init_p,3}}, {status,waiting}, {message_queue_len,0}, {messages,[]}, {links,[]}, {dictionary,[{'$ancestors',[<0.31.0>]}, {'$initial_call',{erl_eval,'

erlang OTP Supervisor crashing

喜欢而已 提交于 2019-11-30 07:13:33
问题 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 server components. My supervisor shouldn't be crashing at all. The code I'm working with is a basic "echo