# `PhoenixMountable.Supervisor`
[🔗](https://github.com/hattoriai/phoenix_mountable/blob/v0.2.1/lib/phoenix_mountable/supervisor.ex#L1)

Starts the processes of every mount of a host router when the host boots.

By default, a mount's processes (`c:PhoenixMountable.children/1`) start the
first time the mount is used: the first request or LiveView. That suits
caches and per-user state, but a scheduler or a poller would not run until
someone opens the library. A host that wants them running from boot adds
this supervisor to its application, after its repo and endpoint:

    children = [
      MyApp.Repo,
      MyAppWeb.Endpoint,
      {PhoenixMountable.Supervisor, router: MyAppWeb.Router, endpoint: MyAppWeb.Endpoint}
    ]

The router knows its mounts at compile time, so nothing else is listed. The
processes then live in the host's supervision tree, under the host's restart
rules.

## Options

  * `:router` (required) — the host router.
  * `:endpoint` — the host endpoint, set as `mount.endpoint` for the
    processes (needed by `PhoenixMountable.PubSub` without a `:pubsub`
    option).
  * `:name` — the supervisor name.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
