1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| 1> c(echo_server). {ok,echo_server}
2> c(echo_server_sup). {ok,echo_server_sup}
%% one_for_one 3> {ok, Pid} = echo_server_sup:start_link(one_for_one, 5, 60). echo_server name:process1 echo_server name:process2 echo_server name:process3 echo_server name:process4 {ok,<0.72.0>}
4> echo_server:stop(whereis(process1), normal). echo_server name:process1 echo_server name:process1 ok
5> echo_server:stop(whereis(process1), kill). echo_server name process1 reason kill. echo_server name:process1 ok
6> =ERROR REPORT==== 23-Mar-2018::01:11:26 === ** Generic server process1 terminating ** Last message in was {stop,kill} ** When Server state == process1 ** Reason for termination == ** kill ** Client <0.60.0> stacktrace ** [{gen,do_call,4,[{file,"gen.erl"},{line,169}]}, {gen_server,call,2,[{file,"gen_server.erl"},{line,202}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {shell,exprs,7,[{file,"shell.erl"},{line,687}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]
6> echo_server:stop(whereis(process1), exit). echo_server name process1 reason exit.
=ERROR REPORT==== 23-Mar-2018::01:11:35 === ** Generic server process1 terminating ** Last message in was {stop,exit} ** When Server state == process1 ** Reason for termination == ** exit ** Client <0.60.0> stacktrace ** [{gen,do_call,4,[{file,"gen.erl"},{line,169}]}, {gen_server,call,2,[{file,"gen_server.erl"},{line,202}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {shell,exprs,7,[{file,"shell.erl"},{line,687}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}] echo_server name:process1 ok
7> echo_server:stop(whereis(process1), shutdown). echo_server name process1 reason shutdown. echo_server name:process1 ok
8> echo_server:stop(whereis(process2), exit). echo_server name process2 reason exit.
=ERROR REPORT==== 23-Mar-2018::01:12:09 === ** Generic server process2 terminating ** Last message in was {stop,exit} ** When Server state == process2 ** Reason for termination == ** exit ** Client <0.60.0> stacktrace ** [{gen,do_call,4,[{file,"gen.erl"},{line,169}]}, {gen_server,call,2,[{file,"gen_server.erl"},{line,202}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {shell,exprs,7,[{file,"shell.erl"},{line,687}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}] ok
9> echo_server:stop(whereis(process3), normal). echo_server name:process3 ok
10> echo_server:stop(whereis(process4), shutdown). echo_server name process4 reason shutdown. ok
%% 子进程确认
11> supervisor:which_children(Pid). [{id_process4,undefined,worker,[echo_server]}, {id_process3,undefined,worker,[echo_server]}, {id_process1,<0.84.0>,worker,[echo_server]}]
12> supervisor:count_children(Pid). [{specs,3},{active,1},{supervisors,0},{workers,3}]
|