Supervisor.init

You're seeing just the function init, go back to Supervisor module for more information.
Link to this function

init(children, options)

View Source (since 1.5.0)

Specs

init([:supervisor.child_spec() | {module(), term()} | module()], [init_option()]) ::
  {:ok, tuple()}

Receives a list of children to initialize and a set of options.

This is typically invoked at the end of the init/1 callback of module-based supervisors. See the sections "Module-based supervisors" and "start_link/2, init/2, and strategies" in the module documentation for more information.

This function returns a tuple containing the supervisor flags and child specifications.

Examples

def init(_init_arg) do
  children = [
    {Stack, [:hello]}
  ]

  Supervisor.init(children, strategy: :one_for_one)
end

Options

  • :strategy - the supervision strategy option. It can be either :one_for_one, :rest_for_one, or :one_for_all

  • :max_restarts - the maximum number of restarts allowed in a time frame. Defaults to 3.

  • :max_seconds - the time frame in seconds in which :max_restarts applies. Defaults to 5.

The :strategy option is required and by default a maximum of 3 restarts is allowed within 5 seconds. Check the Supervisor module for a detailed description of the available strategies.