Roadrunner.Plug (Roadrunner.Plug v0.1.0)

Copy Markdown View Source

Run a Plug on Roadrunner.

Add it to a supervision tree with the plug to serve:

children = [
  {Roadrunner.Plug, plug: MyApp.Router, port: 4000}
]

Options:

  • :plug - the plug to run, as Module or {Module, opts}. Its init/1 runs once, when the listener starts.
  • :port - the TCP port to listen on (default 4000 for :http and 4040 for :https, as Phoenix's other adapters; 0 lets the system pick one, see port/1). A string such as "4000" is accepted.
  • :ip - the local address to bind (default: all interfaces).
  • :scheme - :http (default) or :https.
  • :name - the listener's registered name (default derived from the plug module).
  • :roadrunner - any other :roadrunner_listener option, as a map (protocols, ws, max_clients, ...). Request bodies are read on demand (body_buffering: :manual) with no listener-wide size cap, so Plug.Parsers (or the plug reading the body) sets their limits; set max_content_length here to cap every request anyway.

With scheme: :https, the TLS options are either :tls (:ssl server options as given) or Plug's (:keyfile, :certfile, :key, :cert, :cacertfile, :password, :cipher_suite, :otp_app, ...), resolved by Plug.SSL.configure/1 the way Phoenix's :https endpoint config expects.

Summary

Functions

A child spec that starts the listener under a supervisor.

The port the listener named name bound.

Start the listener, linked to the caller.

Functions

child_spec(opts)

@spec child_spec(keyword()) :: Supervisor.child_spec()

A child spec that starts the listener under a supervisor.

port(name)

@spec port(atom()) :: :inet.port_number()

The port the listener named name bound.

start_link(opts)

@spec start_link(keyword()) :: {:ok, pid()} | {:error, term()}

Start the listener, linked to the caller.