【发布时间】:2012-11-01 08:08:22
【问题描述】:
我尝试使用 Mochiweb 制作一个彗星服务器,例如 there。
如果我从 erlang shell 中执行,没关系。
但是如果尝试从命令行使用 mochiweb 启动第一个节点:
erl -pa ebin edit deps/*/ebin -boot start_sasl -sname n1 -s server +K true -setcookie secret_key -s reloader
第二个带路由器:
erl -pa ebin edit deps/*/ebin -boot start_sasl -sname router -setcookie secret_key -eval 'net_adm:ping(n1@localhost), router:start_link().'
如果我从浏览器连接到 mochiweb,则会出现此错误
=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
我认为问题出在 router.erl 的这个字符串中:
-define(SERVER, global:whereis_name(?MODULE)).
因为 -eval (net_adm:ping(n1@localhost)) 的第一部分启动时没有错误,我可以在 nodes( )。。但是 -eval 的第二部分 (router:start_link()) 不适用于 ?MODULE。
我该如何解决这个问题?
【问题讨论】: