Closed alishir closed 4 years ago
According to documents gproc:reg({n,l,"test"})
will register the current Pid on the local node.
But when I call gproc:reg({n,l,"test"})
from two different Pid of current node, it doesn't prevent registering second process.
As I found registration is done, locally for each process. So two different process can register same name.
Hello,
I created a release project with rebar3 and added gproc as a dependency to it. I also added the gproc to
.app.src
file. But when I runrebar3 shell
and try to register a process globally withgproc:reg({n,g,"test})
I gotlocal_only
exception error. I also tried #119 by setting environment variable in my shell, but doesn't work.would you please help me to register a process golobally?
Regards, Ali
As the README says:
To enable fetching of gen_leader, export the OS environment variableGPROC_DIST=true (this can be done e.g. from a GNU Makefile)
It doesn't state explicitly, perhaps, that the purpose of gen_leader
is to support global registration.
Hello @uwiger,
Thanks for your reply, I also exported GPROC_DIST=true
from my shell and then run rebar3 shell
, but it doesn't work.
I tested both on fish shell and bash.
Yes, when you start gproc
the application environment variable gproc_dist
also needs to be set to e.g. all
.
See https://github.com/uwiger/gproc/blob/a94e1381309f7d79551be7f938459bcd4048abb1/src/gproc_sup.erl#L60
Thanks for your explanation. I added {gproc, [{gproc_dist, all}]}
to the sys.config
and I can retrieve gproc_dist
value from rebar3 shell. Also I exported GPROC_DIST=true
in my shell, But rebar3 compile
and rebar3 shell
doesn't fetch gen_leader
dependency and I got following error:
The above problem resolved by manually adding gen_leader
dependency to the rebar.config
. But still when I call gproc:reg({n,g,"test"})
from cowboy handler I can register under same name twice. I think the expected behavior is first register return true
and the second one cause some error.
Sorry for interruption. It seems I found the problem, cowboy creates a process for each request, after first request the process is terminated so the gproc entry deleted, so the next request can create new entry with the same name.
Hello,
I created a release project with rebar3 and added gproc as a dependency to it. I also added the gproc to
.app.src
file. But when I runrebar3 shell
and try to register a process globally withgproc:reg({n,g,"test})
I gotlocal_only
exception error. I also tried #119 by setting environment variable in my shell, but doesn't work.would you please help me to register a process golobally?
Regards, Ali