Created
February 18, 2019 07:08
-
-
Save mpugach/9093f092f63e5b91f08a8ac116684d66 to your computer and use it in GitHub Desktop.
Elixir Cowboy 2 options example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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