Phoenix.CodeReloader

A plug and module to handle automatic code reloading.

For each request, Phoenix checks if any of the modules previously compiled requires recompilation via __phoenix_recompile__?/0 and then calls mix compile for sources exclusive to the web directory.

To avoid race conditions, all code reloads are funneled through a sequential call operation.

Source

Summary

call(conn, opts)

API used by Plug to invoke the code reloader on every request

init(opts)

API used by Plug to start the code reloader

reload!(paths)

Reloads code within the paths specified in the :reloadable_paths config. This is configured in your application environment like:

touch()

Touches sources that should be recompiled

Functions

call(conn, opts)

API used by Plug to invoke the code reloader on every request.

Source
init(opts)

API used by Plug to start the code reloader.

Source
reload!(paths)

Specs:

  • reload!([binary]) :: :ok | :noop | {:error, binary}

Reloads code within the paths specified in the :reloadable_paths config. This is configured in your application environment like:

config :your_app, YourApp.Endpoint,
  reloadable_paths: ["web"]

Keep in mind that the paths passed to :reloadable_paths must be a subset of the paths specified in the :elixirc_paths option of project/0 in mix.exs.

Source
touch()

Specs:

  • touch :: [binary]

Touches sources that should be recompiled.

This works by checking each compiled Phoenix module if __phoenix_recompile__?/0 returns true and if so it touches it sources file.

Returns the touched source files.

Source