Skip to content

Instantly share code, notes, and snippets.

@mpugach
Created February 18, 2019 07:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpugach/9093f092f63e5b91f08a8ac116684d66 to your computer and use it in GitHub Desktop.
Save mpugach/9093f092f63e5b91f08a8ac116684d66 to your computer and use it in GitHub Desktop.
Elixir Cowboy 2 options example
#https://gitlab.com/stressgrid/dummies/blob/master/elixir_dummy/lib/elixir_dummy/application.ex#L23
defmodule Dummy.Application do
@moduledoc false
use Application
def start(_type, _args) do
dispatch =
:cowboy_router.compile([
{:_,
[
{"/", Dummy, %{}}
]}
])
children = [
%{
id: :dummy,
start:
{:cowboy, :start_clear,
[
:dummy,
%{max_connections: 999_999, socket_opts: [port: 5000]},
%{max_keepalive: 1_000, env: %{dispatch: dispatch}}
]},
restart: :permanent,
shutdown: :infinity,
type: :supervisor
}
]
opts = [strategy: :one_for_one, name: Dummy.Supervisor]
Supervisor.start_link(children, opts)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment