Reputation: 465
In erlang, when I start gen_server module by start_link(A) which includes a parameter,I can't start it twice by changing A. On the console, it shows {error,{already started,<0.61.0>}}. How can I solve the problem? Thank You!
Upvotes: 1
Views: 673
Reputation: 41568
Probably your start_link
call looks something like this:
gen_server:start_link({local, foo}, bar, [], [])
That means, start a gen_server using bar
as the callback module, and register the new process with the name foo
on the local node. If there is already a process named foo
, you'll get the already_started
error.
To start a gen_server without a registered name, thereby making it possible to start any number of them, just drop the first argument:
gen_server:start_link(bar, [], [])
Upvotes: 4