3
votes

liveforeverx on irc has answered my original question and I have modified this question as a followup.

Phoenix depends on Plug for many of its function. However, when it comes to starting cowboy server, why doesn't Phoenix start it using Plug's api in Phoenix.Endpoint.CowboyHandler.start_link? Why does start_link on ranch_listener_sup is called instead?

Is it because of any limitation of Plug or is it because Phoenix started this way much before Plug's api got matured?

My Original Question:

How/where does Phoenix start cowboy?

Reading the Plug docs, I see that to start a server, one has to call

Plug.Adapters.Cowboy.http/3

However, grepping through my phoenix app and the phoenix source code, I do not see any instance of call to Plug.Adapters.Cowboy.http/3. How/where does Phoenix start cowboy?

1
Seems from my point of view, because of integration with websocket stuff.Dmitry Russ

1 Answers

9
votes

Two reasons:

  1. To support websockets

  2. Because Phoenix starts the server inside your application supervision tree instead of running your app inside Cowboy