Stuff Goes Bad:Erlang In Anger

Exercises

Review Questions

[1]. Are Erlang supervision trees started depth-first? breadth-first? Synchronously or asynchronously?
[2]. What are the three application strategies? What do they do?
[3]. What are the main differences between the directory structure of an app and a release?
[4]. When should you use a release?
[5]. Give two examples of the type of state that can go in a process’ init function, and two examples of the type of state that shouldn’t go in a process’ init function

[1]. Erlang supervision树启动时是深度优先(depth-first)还是宽度优先(breadth-first)?
同步的还是异步的?
[2]. 三大application 策略是什么,他们是怎样做的?
[3]. application和release文件夹结构的主要区别是什么?
[4]. 什么情况下要使用release?
[5]. 给出两个应该在初始化里面进行的例子?再给两个不应该在初始化里面进行的例子?

Hands-On

Using the code at https://github.com/ferd/recon_demo:
[1]. Extract the main application hosted in the release to make it independent, and includable in other projects.
[2]. Host the application somewhere (Github, Bitbucket, local server), and build a release with that application as a dependency.
[3]. The main application’s workers (council_member) starts a server and connects to it in its init/1 function. Can you make this connection happen outside of the init function’s? Is there a benefit to doing so in this specific case?

使用这里的code: https://github.com/ferd/recon_demo:
[1]. 提取托管在release中的主application,让他变得独立,可被其它项目包含.
[2]. 把application托管在(Github, Bitbucket, local server)上,然后使用application的依赖项来构建一个release.
[3]. 主application的工作进程(council_member)开启了一个server并在init/1中连接到了它,请将这个连接搬到init/1外面来,再思考一下这一操作有什么具体的好处?