** (UndefinedFunctionError) function SatoriWebsockets.List.start_link/2 is undefined or private

Hi,
I’ve declared the function in my file and called it in application.ex. The error I’m getting is saying start_link/2, however my function is start_link/0. How can I make my application file to take the function exact which is defined.

defmodule SatoriWebsockets.List do
  use GenServer

  def start_link() do
    GenServer.start_link(__MODULE__, nil, name: __MODULE__)
  end

Here’s the application.ex where I’m calling this function:

children = [
      %{
      id: Phoenix.PubSub,
      start: {SatoriWebsockets.List, :start_link, [:index, []]}
      },
      # Start the Telemetry supervisor
      SatoriWebsocketsWeb.Telemetry,
      # Start the Endpoint (http/https)
      SatoriWebsocketsWeb.Endpoint
    ]

Screenshot 2022-12-10 at 7.45.59 PM
Seeking Guidance.

You need your start_link function to accept one argument

See this for more information
https://hexdocs.pm/elixir/Supervisor.html#module-child_spec-1-function

And don’t forget to mark the solution

1 Like