gen event - Erlang: using gen_event global for a remote manager -
i can start event framework fine when register locally:
gen_event:start_link({local, foo_event_container}). gen_event:add_handler(foo_event_container, foo_event_handler, []).
calling registered() shows foo_event_container, , when send messages it, show in handler.
however, when restart node , try
gen_event:start_link({global, foo_event_container}).
registered() not show container, , when try add handler get
** exception exit: noproc in function gen:call/4 in call gen_event:rpc/2
sasl doesn't provide additional info, , googling issue produces guess shell running container has been killed, not case here since i'm trying access same node!
1) ideas what's going on here?
2) having remote container best design, or better have each server use local containers send out messages remote process?
thanks!
local registration , global registration separate namespaces. items registered locally don't show global registrations , vice-versa. (also, local registration names must atoms, while global names can terms)
your global registration should show in global:registered_names/0
, can send globally registered processes either global:send/2
or looking pid global:whereis_name/1
, sending messages pid usual.
you should able add handler doing gen_event:add_handler({global, name}, handler, args)
. gen_*
modules contain code cope process names {global, name}
global
lookup you.
lastly, if start_link
process shell , evaluate expression causes shell crash, process terminated - killed shell error via link. start without link, or start_link under supervisor if want avoid this. it's bad idea link shell process typos shut down processes you're working with.
Comments
Post a Comment