Cherry.Serve (cherry v0.6.1)

Copy Markdown View Source

The dev server: Bandit serving the built _site/, a file watcher that rebuilds on change, and live reload over server-sent events.

Serve mode is the one place Cherry runs long-lived processes; production output stays plain static files.

Summary

Functions

Whether the file watcher is actually running under this serve tree.

Builds the site once, then starts the server + watcher supervision tree.

Functions

live_reload?(supervisor)

@spec live_reload?(pid()) :: boolean()

Whether the file watcher is actually running under this serve tree.

False when the watcher backend was unavailable and Watcher.init/1 degraded to :ignore — the site serves, but without rebuild-on-change.

start(opts)

@spec start(keyword()) ::
  {:ok, pid(), :inet.port_number(), String.t()} | {:error, String.t()}

Builds the site once, then starts the server + watcher supervision tree.

Options: :source (site root, required), :output (default source/_site), :port (default 4000), :verbose (log every request). Returns the supervisor pid, the port actually bound (pass port: 0 for an ephemeral port), and the site's URL prefix — "" for a root site, "/repo" for a base_path site, whose pages then serve under that prefix exactly as production will. Changing base_path needs a serve restart; rebuilds pick up content, not a new prefix.