I’m running a simple cowboy server. Here’s my application file:
defmodule MyApp.Application do
@moduledoc "Application file"
use Application
def start(_type, _args) do
children = [
Plug.Cowboy.child_spec(
scheme: :http,
plug: MyApp.Web.Endpoint,
options: [port: 8000]
)
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
IO.puts("Starting...")
Supervisor.start_link(children, opts) |> IO.inspect
end
end
And here is my endpoint:
defmodule MyApp.Web.Endpoint do
@moduledoc """
This is the module responsible for processing incoming requests
"""
use Plug.Router
import Plug.Conn, only: [send_resp: 3]
plug(Plug.Logger)
plug(:match)
plug(:dispatch)
get "/ping" do
send_resp(conn, 200, "pong")
end
end
After running mix run
, I see the start up log (“Starting…”), but my app exits immediately instead of listening for connections. How do I keep it listening indefinitely?