我不确定我是否能正确表达我的问题,但我会尽我所能。
我发现设置管理树(sup、sup tress和其他更复杂的树)的方式很尴尬。
http://learnyousomeerlang.com/supervisors
我不喜欢这样的想法:启动我的应用程序(管理树),然后在shell上发送erl命令,让应用程序也按我想要的方式运行。以现场的底部外壳为例:
1> supervisor:start_child(band_supervisor, [djembe, good]).
Musician Janet Tennelli, playing the djembe entered the room
{ok,<0.690.0>}
2> supervisor:start_child(band_supervisor, [djembe, good]).
{error,{already_started,<0.690.0>}}
3> supervisor:start_child(band_supervisor, [drum, good]).
Musician Arnold Ramon, playing the drum entered the room
{ok,<0.696.0>}
3> supervisor:start_child(band_supervisor, [guitar, good]).
Musician Wanda Perlstein, playing the guitar entered the room
{ok,<0.698.0>}
4> supervisor:terminate_child(band_supervisor, djembe).
{error,simple_one_for_one}
5> musicians:stop(drum).
Arnold Ramon left the room (drum)
ok
举一个真实的例子,比如说我有一个监听器,在这个监听器上,我说我希望总是有100个监听器。他们的工作是监听监管者创建的套接字。考虑到教程(以及其他在线教程),我必须在shell中输入100次才能启动所有的孩子。
所以,我想我的问题是。。。
如何在应用程序或管理器中完成这一切(无论您想怎么做),以便在启动beam文件后不必在shell中键入任何内容。
谢谢你抽出时间。