Controlling multiple gen_servers with the same module / different arguments

I have an OTP application consisting of one supervisor controlling a small number of gen_servers. A typical specification for children is as follows:

{my_server,
  {my_server, start_link, [123]},
  permanent, 
  5000, 
  worker,
  [my_server]}

No problem so far.

Now I want to add an additional gen_server to the supervisor structure using the same Module / Fn module as above, but with different arguments, for example

{my_server_2,
  {my_server, start_link, [123]},
  permanent, 
  5000, 
  worker,
  [my_server_2]}

I thought this would work, but no:

=SUPERVISOR REPORT==== 15-Apr-2010::16:50:13 ===
     Supervisor: {local,my_sup}
     Context:    start_error
     Reason:     {already_started,<0.179.0>}
     Offender:   [{pid,undefined},
                  {name,my_server_2},
                  {mfa,{my_server,start_link,[]}},
                  {restart_type,permanent},
                  {shutdown,5000},
                  {child_type,worker}]

Do I need to have module arguments in the second element of each child spec?

Thank,

Justin

+3
source share
1 answer

, my_server , gen_server: start_link/4, , , , . gen_servers (gen_server: start_link/3), .

, , . , ?

+6

Source: https://habr.com/ru/post/1741312/


All Articles