Reputation: 11
I try to make a comet-server using Mochiweb like there.
If I do it from erlang shell, it's alright.
But If try to start 1st node with mochiweb from command line:
erl -pa ebin edit deps/*/ebin -boot start_sasl -sname n1 -s server +K true -setcookie secret_key -s reloader
And 2nd one with router:
erl -pa ebin edit deps/*/ebin -boot start_sasl -sname router -setcookie secret_key -eval 'net_adm:ping(n1@localhost), router:start_link().'
If I connect to mochiweb from browser I have this error
=CRASH REPORT==== 18-Jul-2012::19:04:45 ===
crasher:
initial call: mochiweb_acceptor:init/3
pid: <0.73.0>
registered_name: []
exception exit: {noproc,
{gen_server,call,
[undefined,{login,"234567e",<0.73.0>}]}}
in function gen_server:call/2
in call from server_web:loop/2
in call from mochiweb_http:headers/5
ancestors: [server_web,server_sup,<0.55.0>]
messages: []
links: [<0.57.0>,#Port<0.1406>]
dictionary: [{mochiweb_request_qs,
[{"session_id","234567e"},{"obj_id","page"}]},
{mochiweb_request_path,"/polling"}]
trap_exit: false
status: running
heap_size: 2584
stack_size: 24
reductions: 1516
I think that problem is in this string from router.erl:
-define(SERVER, global:whereis_name(?MODULE)).
Because first part of -eval (net_adm:ping(n1@localhost)) was started without errors and I could see n1@localhost in nodes().. But the second part of -eval (router:start_link()) was not available for ?MODULE.
How can I resolve this problem?
Upvotes: 1
Views: 282
Reputation: 2554
Looks like the gen_server that was supposed to be globally registered with name of current module (?MODULE is replaced with it) just has not been started yet. global:whereis_name(?MODULE) will return undefined right in this case, like you see in log you posted.
Find the part of your code that's supposed to do that (by grepping for ?MODULe and/or gen_server:start_link in that module) and make sure it was executed on the first node.
Upvotes: 0