Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 2.73 KB

start-process.md

File metadata and controls

49 lines (37 loc) · 2.73 KB

egg 启动流程 【待续...】

egg启动流程

流程图

    +-------------------+          +----------------------------+          +--------------------------+
    |                   |          |                            |          |                          |
    |   egg-bin dev     +--------> |  egg-cluster startCluster  +--------> |  maser                   +------------+
    |                   |          |                            |          |                          |            |
    +-------------------+          +----------------------------+          +--------------------------+            |
                                                                                                                   |
                                                                                                                   |
                                                                                                                   |
                        +-------------------------------+         +----------------------------------+             |
                        |                               |         |                                  |             |
                        |  agentWorkerLoader            | <-------+  agent_worker  new [Agent]       | <------+    |
                        |                               |         |                                  |        |    |
                        +-------------------------------+         +----------------------------------+        |    |
                                                                                                              +----+
                                                                                                              |
                        +-------------------------------+         +----------------------------------+        |
                        |                               |         |                                  |        |
                        |  appWorkerLoader              | <-------+  app_worker new [Application]    | <------+
                        |                               |         |                                  |
                        +-------------------------------+         +----------------------------------+



流程详解

注:以启动 npm run dev为例

  • 在项目目录下启动npm run dev执行了egg-bin dev
  • egg-bin 命令执行了 eggstartCluster()方法
  • startCluster是直接引用 require('egg-cluster').startCluster
  • egg-cluster模块启动了两种worker
    • agent_worker
      • egg.Agent()
      • 用于进程守护和其他非业务操作
    • app_worker
      • egg.Application()
      • 业务操作进程