application.ex 881 Bytes
Newer Older
KT315's avatar
KT315 committed
1 2 3 4 5 6 7 8 9 10
defmodule Dummy.Application do
  @moduledoc false

  use Application

  def start(_type, _args) do
    dispatch =
      :cowboy_router.compile([
        {:_,
         [
KT315's avatar
KT315 committed
11
           {"/", Dummy, %{}}
KT315's avatar
KT315 committed
12 13 14 15 16 17 18 19 20 21 22
         ]}
      ])

    children = [
      %{
        id: :dummy,
        start:
          {:cowboy, :start_clear,
           [
             :dummy,
             %{num_acceptors: 10, max_connections: 999_999, socket_opts: [port: 5000]},
KT315's avatar
KT315 committed
23 24 25 26 27 28
             %{
               max_keepalive: 1_000,
               max_received_frame_rate: {1_000_000, 1},
               env: %{dispatch: dispatch},
               stream_handlers: [Dummy.FastStream]
             }
KT315's avatar
KT315 committed
29 30 31 32 33 34 35 36 37 38 39
           ]},
        restart: :permanent,
        shutdown: :infinity,
        type: :supervisor
      }
    ]

    opts = [strategy: :one_for_one, name: Dummy.Supervisor]
    Supervisor.start_link(children, opts)
  end
end