Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Phoenix doesn't use Plug to start the server?

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?

like image 915
shankardevy Avatar asked Dec 06 '25 04:12

shankardevy


1 Answers

Two reasons:

  1. To support websockets

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

like image 117
José Valim Avatar answered Dec 09 '25 03:12

José Valim