[erlang-questions] problem with global registration

Garry Hodgson garry@REDACTED
Tue Nov 7 19:54:01 CET 2006


i'm having some trouble with the global registration that's
implied by passing { global, ?MODULE } to the gen_server:start
that i call in a module's start() routine.  i want to centralize
logging, and be able to enable/disable log levels on the fly for
debug purposes.  

specifically, i want to run my server the usual way, and then
use the "-run" arg to erl to run another erlang program to disable
logging.  so i use:

    erl -sname debug -setcookie keebler -run master debugctrl on

the function this invokes is:

    debugctrl( [ OnOff ] ) ->
        case OnOff of
            "on" ->
                util:enable( debug );
            "off" ->
                util:disable( debug )
        end,
        halt().

the util:enable() function that this calls is:

    enable( Log ) ->
        gen_server:call( { global, util }, { enable, Log }, 10000 ).


when i run the control program, it fails, reporting the following:

    {"init terminating in do_boot",
        {noproc,{gen_server,call,[{global,util},{enable,debug},10000]}}}

if i run my server in the erlang shell, then i can run "util:enable( debug)."
and it works fine.  of course, that's running in the same node.

the util process is started using { global, util }.
my understanding is that this would globally register it.
all the cookies match.  it's running on the same machine
(although i'll need to be able to do the same thing from
other machines).  this application is not being run via 
otp proper (i.e. the supervisor/app/release/etc stuff).
it's an older app that i'm slowly converting, using gen_server
whenever i need to add a new process.

so, anyone want to tell me what detail i've foolishly overlooked?
or whether i'm just completely off base.  suggestions for a better
approach are welcome, as well.

thanks

----
Garry Hodgson, Senior Software Geek, AT&T CSO

But I'm not giving in an inch to fear
'Cause I promised myself this year
I feel like I owe it...to someone.




More information about the erlang-questions mailing list