=ERROR REPORT==== 11-Apr-2009::01:51:47 ===
** Generic server test terminating
** Last message in was error
** When Server state == []
** Reason for termination ==
** error
gen_server test is started (test重启时所输出的信息)
** exception exit: {error,{gen_server,call,[test,error]}}
in function gen_server:call/2
13>
=ERROR REPORT==== 11-Apr-2009::01:51:47 ===
** Generic server sup terminating
** Last message in was {'EXIT',<0.54.0>,
{{error,{gen_server,call,[test,error]}},
可见sup系因为收到‘EXIT’信息才崩溃的,大白天谁无缘无故发个‘EXIT’信息出来?Google一番后在Google Groups里找到解答如下:
在erlshell里测试,需要unlink supervisor,这是因为在shell里运行时,进程层次状况如下:
shell
eval_loop
sup
这几个进程是link起来的,如不unlink,在出错时eval_loop会退出重启,导致sup收到{'EXIT', Pid, _}而发生退出。
OK,据此稍为修改监督者的启动函数即可:
{ok, Pid} = supervisor:start_link({local, sup}, sup, []),
unlink(Pid).
0 意見