Caddy (Caddy v2.0.0)

Caddy

Start Caddy HTTP Server in supervisor tree

  • Start in your application
def start(_type, _args) do
  children = [
    # Start a Caddy by calling: Caddy.start_link([])
    {Caddy, [
      caddy_bin: "/usr/bin/caddy",
    ]}
    # Start the Telemetry supervisor
    PhoenixWeb.Telemetry,
    # Start the PubSub system
    {Phoenix.PubSub, name: PhoenixWeb.PubSub},
    # Start the Endpoint (http/https)
    PhoenixWeb.Endpoint
  ]

  opts = [strategy: :one_for_one, name: PhoenixWeb.Supervisor]
  Supervisor.start_link(children, opts)
end
  • Start in extra_applications
def application do
  [
    extra_applications: [Caddy.Application]
  ]
end
  • Notice

If caddy_bin is not specifiy, Caddy.Server will not start. You can set it latter by Caddy.Config.set_bin("path/to/caddy") and restart server by Caddy.restart_server()

Summary

Functions

Returns a specification to start this module under a supervisor.

Restart Caddy Server

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

restart_server()

Restart Caddy Server

start()

@spec start() :: :ignore | {:error, any()} | {:ok, pid()}

start(list)

@spec start([{:caddy_bin, binary()}]) :: :ignore | {:error, any()} | {:ok, pid()}

start_link(args)

@spec start_link(Keyword.t()) :: :ignore | {:error, any()} | {:ok, pid()}

stop(reason \\ :normal)

@spec stop(term()) :: :ok