PhoenixMountable.Supervisor (PhoenixMountable v0.2.1)

Copy Markdown View Source

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

By default, a mount's processes (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.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.