先把该应用原来的启动配置发下: 根据,OTP设计文档中,启动策略有三类:
点击(此处)折叠或打开
- start_xxapp() ->
- case supervisor:start_child(
- game_server_sup,
- {mod_xx,
- {mod_xx, start_link,[]},
- transient, infinity, supervisor, [mod_xx]}) of
- {ok, Pid} ->
- timer:sleep(1000),
- Pid;
- _ ->
- undefined
- end.
1、permanent 应用挂掉之后,其他所有的应用和运行中的系统跟着一起遭遇,都会挂
2、transient 应用收到normal终止信号时,其他应用和运行中的系统不熟影响,收到shutdown终止信号时,效果就和permanent一样了。由于,监督树的终止信号shutdown,所以,启动监督树的时候通常不用这个参数。
3、temporary 独立,该应用的死活不会影响到其他应用和runtine-time system
根据这些规则,将上面的应用启动改成:
点击(此处)折叠或打开
- start_xxapp() ->
- case supervisor:start_child(
- game_server_sup,
- {mod_xx,
- {mod_xx, start_link,[]},
- temporary, 2000, supervisor, [mod_xx]}) of
- {ok, Pid} ->
- timer:sleep(1000),
- Pid;
- _ ->
- undefined
- end.