# `Juggernaut.Peer.Reload`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/peer/reload.ex#L1)

Hot loading in a warm worker after the sandbox was compiled again (design notes §10.9):
the server's pool outlives a run, so before the next run's jobs every loaded module
whose beam under the sandbox changed is loaded again.

For each such module, `:code.soft_purge/1` first; if a process still runs the module's
old code the worker must be recycled instead (nothing is loaded, the answer names the
module). Otherwise the changed modules are loaded together, from their files, with `:code.atomic_load/1`.
Call counting (`Juggernaut.Peer.Footprint`) is armed per loaded module, so it is
disarmed after a reload and arms again on the next measured job.

Modules not loaded yet are left to the code server, which loads them from the sandbox
on first use. This module runs inside workers and is never mutated.

# `run`

```elixir
@spec run(Path.t()) :: {:ok, [module()]} | {:recycle, String.t()}
```

Loads again every module loaded from under `root` (the sandbox) whose beam on disk
differs from the loaded code. Returns `{:ok, modules}` (possibly empty) or
`{:recycle, reason}`.

# `stale`

```elixir
@spec stale(Path.t()) :: [module()]
```

The loaded modules whose beam file under `root` differs from the loaded code.

---

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