Supervisor, tuple child-spec: possible with multiple arguments?

Hi alchemists!

Can someone please tell me how those tuple child specifications are supposed to work? I’m trying to start a PubSub server like this:

children = [
  {Phoenix.PubSub.PG2, [MyApp.PubSub, []]}  # <= 2 arguments to PG2's init
]
Supervisor.start_link(children, [strategy: :one_for_one]

The error effectively tells me that the second term in the tuple is treated as a single argument instead of as a list of arguments:

** (Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Phoenix.PubSub.PG2
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function Phoenix.PubSub.PG2.start_link/1 is undefined or private. Did you mean one of:

      * start_link/2

            (phoenix_pubsub) Phoenix.PubSub.PG2.start_link([MyApp.PubSub, []])

Is this a bug, or is there any other way to specify more than one argument using this notation?

1 Like

The new child-specs only support start_link/1 function (unless the module overrides the child_spec/1 function).

4 Likes