I implemented gen_server and supervisor: test_server and test_sup . I want to test them from the shell / CLI. I wrote my start_link functions start_link that their names are registered locally.
I found that I can spawn test_server from the command line just fine, but spawned test_sup does not allow me to interact with the server at all.
For example, I can create test_server by doing:
1> spawn(test_server, start_link, []). <0.39.0> 2> registered(). [...,test_server,...]
I can interact with the server and everything looks fine.
However, if I try to do the same with test_sup , no new names / Pids will be registered in my "CLI process" (using registered/0 ). My test_server seems to have been spawned, but I can't interact with it (see Lucas Larsson's comment on SASL to see why this is).
I would suggest that I encoded the error in my supervisor, but this method of starting my supervisor works fine:
1> {ok, Pid}= test_sup:start_link([]). {ok, <0.39.0>} 2> unlink(Pid). true 3> registered(). [...,test_server,test_sup,...]
Why can I spawn gen_server but not a supervisor?
Update
The code I'm using can be found in this post . I use echo_server and echo_sup , two very simple modules.
Given this code, this works:
spawn(echo_server, start_link, []).
and this is not so:
spawn(echo_sup, start_link, []).