Eralng simple

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]). s

Eralng简单

我有一个测试模块和一个simple_one_for_one主管。 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()

unable to start rabbitmq

I installed rabbitmq using homebrew. I am trying to start rabbitmq server but I always get this error which I am unable to figure out why! I have erlang installed and there is no other application running on the same port. $ rabbitmq-server {error_logger,{{2013,2,11},{22,37,49}},"Can't set short node name!nPlease check your configurationn",[]} {error_logger,{{2013,2,11},{22,37,49}},crash_re

无法启动rabbitmq

我用自制软件安装了rabbitmq。 我试图启动rabbitmq服务器,但我总是得到这个错误,我无法弄清楚为什么! 我安装了erlang,并且没有其他应用程序在同一端口上运行。 $ rabbitmq-server {error_logger,{{2013,2,11},{22,37,49}},"Can't set short node name!nPlease check your configurationn",[]} {error_logger,{{2013,2,11},{22,37,49}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,},{regist

Cannot spawn an erlang supervisor from the shell

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 t

无法从shell生成erlang管理程序

我已经实现了gen_server和supervisor: test_server和test_sup 。 我想从shell / CLI测试它们。 我写了他们的start_link函数,以便他们的名字在本地注册。 我发现我可以从命令行产生test_server ,但是产生的test_sup根本不允许我与服务器进行交互。 例如,我可以通过执行以下命令产生一个test_server : 1> spawn(test_server, start_link, []). <0.39.0> 2> registered(). [...,test_server,...] 我可以与

Erlang how to set up a supervisor tree application that is self contained

I am not sure if I can properly articulate my question, but I will try as best I can. I find it awkward the way you have to set up a supervisor tree(sup, sup-tress, and other more complex trees). Lets take for example, the following (I have already made these examples and expanded on them): http://learnyousomeerlang.com/supervisors I dont like the idea of starting my application(supervisor

Erlang如何设置自包含的主管树应用程序

我不确定我是否可以正确地表达我的问题,但我会尽我所能。 我发现你不得不建立一个主管树(sup,supressress,和其他更复杂的树)的方式很尴尬。 让我们举例来说,以下(我已经提出这些例子并对其进行了扩展):http://learnyousomeerlang.com/supervisors 我不喜欢启动我的应用程序(supervisor树)的想法,然后必须在shell上发送erl命令来让应用程序按照我的需要行事。 以该网站的底部壳体示例为例: 1> supervisor:

Collecting info about simple

I have a supervisor (called alice) which starts a bunch of_one_for_one workers. Now I'd like to get some info about all of the works together. For instance, let's say workers are TCP servers and I'd like to get all port numbers used by workers, or all remote addresses which are connected to those workers. Where should I put this functionality? Supervisor doesn't have gen_serv

收集关于简单的信息

我有一个主管(称为爱丽丝),它开始了一堆工作。 现在我想了解所有这些作品的一些信息。 例如,假设工作人员是TCP服务器,并且我希望获取工作人员使用的所有端口号,或者所有连接到这些工作人员的远程地址。 我应该在哪里放置这个功能? Supervisor没有gen_server功能,并且无法应答呼叫。 所以,在我看来,最合理的方法是让另一位主管(称为bob)产生主管爱丽丝,另一个gen_server(charile)通过呼叫主管实现如{get,po

Erlang supervisor and supervisor child

I have a question about supervisor. For example I have 1 supervisor and I need execute some start_child for this supervisor. Must I start first of all start my supervisor? Or can I only supervisor:start_child(my_sup,[]) without my_sup starting? Thank you. First you create a supervisor process as part of a supervision tree calling supervisor:start_link/2 or supervisor:start_link/3 . The cr

Erlang主管和主管孩子

我有一个关于主管的问题。 例如,我有1个主管,我需要为这个主管执行一些start_child。 我必须首先启动我的主管? 或者我可以只supervisor:start_child(my_sup,[])没有启动my_sup吗? 谢谢。 首先,创建一个监督员流程作为监督树的一部分,称为supervisor:start_link/2或supervisor:start_link/3 。 创建的主管进程调用Module:init/1来查找重启策略,最大重启频率和子规格。 这是启动gen_server的主管的示例代码(不过

server and state

As an exercise to test my understanding of sequential Erlang I wrote a simple-minded html tag editor. It maintains a current position in the text, eg edit state, in a record like this: -record(ed_txt, {a=[], b=[], c=[]). ...where a holds text above the current paragraph, b holds the current paragraph, and c holds text below the current paragraph. It is called like this: tag(App, FileName)

服务器和状态

作为一个练习来测试我对顺序Erlang的理解,我写了一个简单的html标签编辑器。 它在文本中维护当前位置,例如编辑状态,如下所示: -record(ed_txt, {a=[], b=[], c=[]). ...当前段落上方保留文本,b保存当前段落,c保存当前段落下方的文本。 它被这样调用: tag(App, FileName) -> {ok, File1} = get_file(App, FileName), {ok, File2} = file_to_paragraphs(File1), {ok, Record} = create_record(File2),

Erlang Dynamic supervisor start gen

I have root supervisor that create other supervisor: start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). init([]) -> RestartStrategy = {one_for_one, 5, 600}, ListenerSup = {popd_listener_sup, {popd_listener_sup, start_link, []}, permanent, 2000, supervisor, [popd_listener]}, Children = [ListenerSup], {ok, {Restar

Erlang Dynamic supervisor启动gen

我有创建其他主管的root主管: start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). init([]) -> RestartStrategy = {one_for_one, 5, 600}, ListenerSup = {popd_listener_sup, {popd_listener_sup, start_link, []}, permanent, 2000, supervisor, [popd_listener]}, Children = [ListenerSup], {ok, {RestartStrategy, Children}}.

server processes with timeout

I have to implement erlang gen_server processes which are alive for hours. But after timeout gen_server process should be killed. These processes are started dynamically so dynamical supervising is used. The idea is to use timer:apply_after() on process init. So init of gen_server process looks like that init(Time) -> timer:apply_after(Time, my_supervisor, kill_child, [self()]), %

服务器进程超时

我必须实施erlang gen_server进程,这些进程已经存在了好几个小时。 但超时后gen_server进程应该被终止。 这些过程是动态启动的,因此使用动态监督。 这个想法是在进程init上使用timer:apply_after()。 所以gen_server进程的init看起来就像那样 init(Time) -> timer:apply_after(Time, my_supervisor, kill_child, [self()]), % do other init things ok. 我对erlang有点新,所以问题是这种方法是好的还是

Added supervisor(s) for a gen

EDIT: Below. Why is my supervised gen_server shutting down so quickly? I'll give these organizational names to make it more clear the chain of command that I want in my application: First I'm starting with the "assembly_line_worker" then later I'll add the "marketing_specialist" to my supervision tree... ceo_supervisor.erl -module(ceo_supervisor). -behaviour

添加了一个gen的主管

编辑:下面。 为什么我监督的gen_server如此快速地关闭? 我会给这些组织名称,使其更清楚我的应用程序中需要的命令链:首先,我先从“assembly_line_worker”开始,然后再将“marketing_specialist”添加到我的监督树中。 ceo_supervisor.erl -module(ceo_supervisor). -behaviour(supervisor). -export([start_link/1]). -export([init/1]). start_link(State) -> supervisor:start_link({local,?MODULE}, ?MODULE