Cherry.Serve (cherry v0.2.0)

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()} | {: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 and the port actually bound (pass port: 0 for an ephemeral port).