包详细信息

egg-cluster

eggjs98.6kMIT2.4.0

cluster manager for egg

egg, cluster, process

自述文件

egg-cluster

NPM version CI Test coverage Known Vulnerabilities npm download

Cluster Manager for EggJS


Install

npm i egg-cluster --save

Usage

const startCluster = require('egg-cluster').startCluster;
startCluster({
  baseDir: '/path/to/app',
  framework: '/path/to/framework',
});

You can specify a callback that will be invoked when application has started. However, master process will exit when catch an error.

startCluster(options, () => {
  console.log('started');
});

Options

Param Type Description
baseDir String directory of application
framework String specify framework that can be absolute path or npm package
plugins Object plugins for unittest
workers Number numbers of app workers
sticky Boolean sticky mode server
port Number port
debugPort Number the debug port only listen on http protocol
https Object start a https server, note: key / cert / ca should be full path to file
require `Array\ String` will inject into worker/agent process
pidFile String will save master pid to this file
startMode String default is 'process', use 'worker_threads' to start the app & agent worker by worker_threads
ports Array startup port of each app worker, such as: [7001, 7002, 7003], only effects when the startMode is 'worker_threads'
env String custom env, default is process.env.EGG_SERVER_ENV

Env

EGG_APP_CLOSE_TIMEOUT: app worker boot timeout value

EGG_AGENT_CLOSE_TIMEOUT: agent worker boot timeout value

License

MIT

Contributors

Contributors

Made with contributors-img.

更新日志

Changelog

2.4.0 (2024-12-09)

Features

2.3.0 (2024-06-03)

Features

2.2.1 (2023-12-08)

Bug Fixes

  • worker does not get SIGTERM signal from master when close (#111) (211c143)

2.2.0 (2023-06-27)

Features

  • add debugPort to allow listen both https and http protocol (#109) (74cbb35)

2.1.1 (2023-06-06)

Bug Fixes

  • worker_threads start auto add port when server.address() return null (#108) (62d6d0b)

2.1.0 (2023-05-31)

Features

2.0.1 (2022-12-19)

Bug Fixes


2.0.0 / 2022-11-02

features

1.27.1 / 2021-11-15

others

1.27.0 / 2021-04-05

features

1.26.0 / 2019-11-18

features

1.25.0 / 2019-07-24

features

fixes

1.24.0 / 2019-06-14

features

1.23.3 / 2019-05-27

fixes

1.23.2 / 2019-04-08

fixes

1.23.1 / 2019-03-12

others

1.23.0 / 2019-03-04

features

1.22.2 / 2018-12-04

fixes

others

1.22.1 / 2018-10-19

  • fix: should not start app when agent start fail (#81)

1.22.0 / 2018-10-10

features

1.21.0 / 2018-09-28

  • feat: graceful exit when boot failed (#78)

1.20.0 / 2018-09-17

  • feat: kill agent after workers are killed (#76)
  • docs: fix typo (#77)

1.19.1 / 2018-08-27

fixes

1.19.0 / 2018-07-26

  • feat: support options.require (#73)
  • feat: replace worker file from outside (#72)

1.18.0 / 2018-06-12

  • feat: support config agent debug port (#70)

1.17.0 / 2018-06-06

features

1.16.1 / 2018-05-16

  • fix: use --inspect-port after 8.x (#69)
  • fix: remove useless unittest (#65)
  • fix: master close log print timeout error (#64)

1.16.0 / 2018-03-28

  • fix: wait 5s when master exit (#60)
  • feat: add typescript support (#61)

1.15.0 / 2018-03-05

features

others

1.14.0 / 2018-02-05

features

1.13.1 / 2018-01-05

others

1.13.0 / 2017-12-05

features

1.12.6 / 2017-11-21

fixes

1.12.5 / 2017-11-16

fixes

others

1.12.4 / 2017-10-29

others

1.12.3 / 2017-10-12

fixes

1.12.2 / 2017-09-28

fixes

1.12.1 / 2017-09-22

fixes

1.12.0 / 2017-09-14

features

1.11.2 / 2017-09-13

features

others

1.11.1 / 2017-09-11

fixes

1.11.0 / 2017-09-08

features

others

1.10.0 / 2017-09-07

others

1.9.2 / 2017-08-30

fixes

1.9.1 / 2017-08-28

  • fix: sleep 100ms to make sure SIGTERM send to the child processes (#37)
  • test: fix test that should mock the default port (#38)

1.9.0 / 2017-07-27

  • feat: add listen config (#34)
  • refactor: disable console (#36)
  • deps: upgrade eslint (#35)
  • refactor: set agent worker and app worker console level (#33)
  • deps: upgrade dependencies (#32)

1.8.0 / 2017-06-12

  • feat: use graceful-process to refactor app and agent worker (#30)
  • test: sleep 20s to wait for agent process start (#29)

1.7.0 / 2017-06-09

  • feat: reduce info logs on local env (#28)

1.6.4 / 2017-05-28

  • fix: agent should exit on disconnect event whatever master kill with SIGKILL (#27)

1.6.3 / 2017-05-22

  • fix: fix typo (#24)
  • fix: start error should log what happend (#26)
  • fix: fix deperated api (#25)
  • deps: upgrade dependencies (#22)

1.6.2 / 2017-03-22

  • fix: should print logger when agent start error (#20)

1.6.1 / 2017-03-03

  • fix: sticky logic error (#19)
  • feat: use egg-utils (#18)

1.6.0 / 2017-03-01

  • feat: add options framework (#17)

1.5.0 / 2017-02-21

  • feat: exit when error emitted during start (#16)

1.4.0 / 2017-02-13

  • feat:add sticky cluster mode (#14)
  • test: add test for agent debug port (#13)

1.3.0 / 2017-01-20

  • feat: get clusterPort (#12)

1.2.0 / 2016-12-26

  • feat: npm publish files limit (#10)

1.1.0 / 2016-12-20

  • deps: upgrade dependencies
  • refactor: options should be passed through
  • feat: print env when start (#8)

1.0.0 / 2016-10-12

  • feat: exit if worker start timeout (#6)

0.2.0 / 2016-10-12

  • feat: when debug mode, master should exit when worker die (#7)
  • test: fix testcase (#5)

0.1.0 / 2016-08-16

  • feat: [BREAKING_CHANGE] master won't load config (#4)
  • test: add test cases (#3)

0.0.4 / 2016-07-16

  • fix: remove antx loader (#2)

0.0.3 / 2016-07-16

  • fix: loader version (#1)
  • fix: logger

0.0.2 / 2016-07-15

  • init code