+-------------------+ +----------------------------+ +--------------------------+
| | | | | |
| 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
命令执行了egg
的startCluster()
方法startCluster
是直接引用require('egg-cluster').startCluster
egg-cluster
模块启动了两种worker
- agent_worker
egg.Agent()
- 用于进程守护和其他非业务操作
- app_worker
egg.Application()
- 业务操作进程
- agent_worker