[英]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. irc上的liveforeverx回答了我原来的问题,我已将此问题修改为后续问题。
Phoenix depends on Plug for many of its function. Phoenix的许多功能都依赖于Plug。 However, when it comes to starting cowboy server, why doesn't Phoenix start it using Plug's api in Phoenix.Endpoint.CowboyHandler.start_link?
但是,当谈到启动牛仔服务器时,凤凰为什么不在Phoenix.Endpoint.CowboyHandler.start_link中使用Plug的api启动呢? Why does start_link on ranch_listener_sup is called instead?
为什么要调用ranch_listener_sup上的start_link呢?
Is it because of any limitation of Plug or is it because Phoenix started this way much before Plug's api got matured? 是因为Plug的任何限制还是因为Phoenix在Plug的api成熟之前就开始了这么多?
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文档,我看到要启动服务器,必须调用
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
. 但是,通过我的凤凰应用程序和凤凰源代码,我没有看到任何调用
Plug.Adapters.Cowboy.http/3
实例。 How/where does Phoenix start cowboy? 菲尼克斯如何/在哪里开始牛仔?
Two reasons: 两个原因:
To support websockets 支持websockets
Because Phoenix starts the server inside your application supervision tree instead of running your app inside Cowboy 因为Phoenix在应用程序监督树中启动服务器而不是在Cowboy中运行您的应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.