# `mix juggernaut.server`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/mix/tasks/juggernaut.server.ex#L1)

Starts the single warm daemon for this checkout: one pool of test workers and a job
queue. `mix juggernaut` and `mix juggernaut.check` attach to it when it is reachable
(unless given `--no-server`), which skips booting workers for each run.

    mix juggernaut.server [--workers N] [--idle-timeout DURATION] [--watch]
    mix juggernaut.server --status
    mix juggernaut.server --stop

It listens on `127.0.0.1` only and every request must carry the token in
`_build/juggernaut/server/token` (mode 0600). It holds the checkout lock while it runs,
so a run with `--no-server` meanwhile is refused (exit 3) rather than booting a second
pool. Requests queue first in, first out; a client waiting behind others is told its
position. The pool boots with the first run (that run's compile builds the sandbox the
workers load) and is kept while the config fingerprint, `mix.exs`, `config/` and the
test files stay the same; before each run its workers load the beams the run's compile
changed. A run's own `--workers` does not resize a warm pool. With `--watch` it also
runs the inner lane on every saved change and lives as long as the watch (the idle
timeout is off). It stops after `--idle-timeout` without requests (not with `--watch`),
on `--stop`, or on Ctrl-C.

## Options

  * `--workers N` - Pool size (default from `.juggernaut.exs`).
  * `--idle-timeout DURATION` - Stop after this long without requests; `0` means never. Not used with `--watch`. Default: `30m`.
  * `--watch` - Also run the inner lane on every saved change; the server then lives as long as the watch, with no idle timeout.
  * `--stop` - Stop the running server.
  * `--force-unlock` - Remove the checkout lock first, whoever holds it: for a server or run whose container was removed before its lock went stale.
  * `--status` - Show the running server's address, pool and queue.

## Exit codes

  * 0 - stopped cleanly
  * 2 - a server is already running (its address is printed), or a usage error
  * 3 - the server could not start (the checkout lock is held, or it cannot listen)

# `await`

```elixir
@spec await(reference()) :: :ok | {:error, Juggernaut.Error.t()}
```

Waits for the server monitored by `ref` to stop: `:ok` when it stopped normally.

# `server_opts`

```elixir
@spec server_opts(keyword(), map()) :: keyword()
```

The `Juggernaut.Server` options of this task's flags and context.

# `status_text`

```elixir
@spec status_text(map()) :: String.t()
```

The human line of a server's status.

---

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