diff --git a/CHANGELOG.md b/CHANGELOG.md index 1858fa0..93bcb8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,88 +2,107 @@ CHANGELOG ========= This project is using [Semantic Versioning 2.0.0](http://semver.org/) +1.0.0 +----- + +After successfully running **division** on production over one year - version 1.0.0. has been finally released. + +#### Fixes + * Improve handling with broken workers. Now `master` will stop his work when a many `workers` has been killed in 5 minutes since last incident. + **NOTE:** This change could be incompatible for some applications, but most of them probably will not even notice. + * Remove all listeners from process instance, that was added by `master` process. + +#### Other + * Make number of allowed `workers` suicides to be configurable (defaults to 30). + * Add more unit tests. + * Implement code coverage. + * Implement code linter. + * Move documentation to separate file (API.md). + 0.4.5 ----- #### Fixes - * Fix error with writing error messages when `debug` extension was not enabled + * Fix error with writing error messages when `debug` extension was not enabled. #### Other - * Some code cleanup - * Finished version of documentation + * Some code cleanup. + * Finished version of documentation. 0.4.4 ----- #### Fixes - * Fix error 'IPC channel is already disconnected' in test suite + * Fix error 'IPC channel is already disconnected' in test suite. #### Other - * Update part of documentation + * Update part of documentation. 0.4.3 ----- #### Fixes - * Fix test suite for Travis CI + * Fix test suite for Travis CI. #### Other - * Increase threshold for fast exiting workers - * Changed `npm test` reporter to more readable + * Increase threshold for fast exiting workers. + * Changed `npm test` reporter to more readable. 0.4.2 ----- #### Fixes - * Fix inconsistency of workers count when calling `increase` and `decrease` in short time period - * Fix bug with resolving paths in `watch` extension + * Fix inconsistency of workers count when calling `increase` and `decrease` in short time period. + * Fix bug with resolving paths in `watch` extension. #### Other - * Decrease delay of spawning new workers when previous one exited - * Add new test cases for `watch` extension + * Decrease delay of spawning new workers when previous one exited. + * Add new test cases for `watch` extension. 0.4.1 ----- #### Fixes - * Fixed next case when program crashed with many **division** instances runs at once + * Fixed next case when program crashed with many **division** instances runs at once. 0.4.0 ----- #### Features - * New extension - `watch` + * New extension - `watch`. #### Fixes - * Fixed bug with `debug` extension, which crash application when could not read properties of dead worker - * Fixed bug with `use` method, which crash system when cannot find extension to be required - * Fixed bug with `close` in Worker, which not always killing disconnected process - * Fixed bug when many **division** instances runs in one process + * Fixed bug with `debug` extension, which crash application when could not read properties of dead worker. + * Fixed bug with `use` method, which crash system when cannot find extension to be required. + * Fixed bug with `close` in Worker, which not always killing disconnected process. + * Fixed bug when many **division** instances runs in one process. #### Other - * Added this file (CHANGELOG.md) - * Added basic test suite and Travis CI support - * Removed dependency of grunt in favour of CoffeeScript (Cakefile) + * Added this file (CHANGELOG.md). + * Added basic test suite and Travis CI support. + * Removed dependency of grunt in favor of CoffeeScript (Cakefile). 0.3.0 ----- #### Features - * New extension - `debug` + * New extension - `debug`. #### Fixes - * Fixed `decrease` method, which don't working overall + * Fixed `decrease` method, which don't working overall. #### Other - * Listed public attributes and methods in README.md + * Listed public attributes and methods in README.md. 0.2.0 ----- #### Features - * Added ability to use extensions - * New extension - `signals` + * Added ability to use extensions. + * New extension - `signals`. 0.1.0 ----- -Initial version + +Initial version. + diff --git a/README.md b/README.md index 6a658fe..600f588 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ division [![](https://img.shields.io/travis/codename-/division.svg?style=flat)](https://travis-ci.org/codename-/division) [![](https://img.shields.io/coveralls/codename-/division.svg?style=flat)](https://coveralls.io/r/codename-/division) ![](https://img.shields.io/node/v/division.svg?style=flat) [ ![](https://img.shields.io/npm/v/division.svg?style=flat)](https://npmjs.org/package/division) ![](https://img.shields.io/npm/l/division.svg?style=flat) ![](https://img.shields.io/npm/dm/division.svg?style=flat) -Simple and powerful wrapper over [node.js](http://nodejs.org/) [cluster](http://nodejs.org/api/cluster.html) API.
-This module is inspired by impressive but abandoned project [Cluster](https://github.com/LearnBoost/cluster) created by [@visionmedia](https://github.com/visionmedia). +Simple yet powerful wrapper over [node.js](http://nodejs.org/) [cluster](http://nodejs.org/api/cluster.html) API.
+This module is inspired by impressive, but abandoned project [Cluster](https://github.com/LearnBoost/cluster) created by [TJ Holowaychuk](https://github.com/tj). ## Installation diff --git a/package.json b/package.json index f38f378..d797821 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "division", - "version": "0.4.5", - "description": "Simple and powerful wrapper over node.js cluster API. This module is inspired by impressive but abandoned project Cluster created by visionmedia (TJ Holowaychuk)", + "version": "1.0.0", + "description": "Simple yet powerful wrapper over node.js cluster API. This module is inspired by impressive, but abandoned project Cluster created by TJ Holowaychuk.", "author": "codename-", "main": "lib/division.js", "devDependencies": { "coffee-script": "^1.8.0", "coffeelint": "^1.6.1", "coveralls": "^2.11.2", - "istanbul": "^0.3.2", + "istanbul": "^0.3.5", "mocha": "^2.0.1", "should": "^4.3.0" }, diff --git a/src/master.coffee b/src/master.coffee index 287645d..e71d2a3 100644 --- a/src/master.coffee +++ b/src/master.coffee @@ -34,6 +34,8 @@ module.exports = class Master extends EventEmitter __define '__killed', writable: yes, value: 0 __define '__incident', writable: yes, value: 0 + __define '__listeners', writable: yes, value: [] + ############################ # # Define public methods @@ -44,7 +46,15 @@ module.exports = class Master extends EventEmitter # Register signal __define 'addSignalListener', enumerable: yes, value: (event_or_signal, callback) -> - process.on event_or_signal, callback.bind this + # Bind scope of callback + callback = callback.bind this + + # Save information about added signal listeners + @__listeners.push [event_or_signal, callback] + + # Add signal listener to the process + process.on event_or_signal, callback + return this ## Runtime @@ -224,11 +234,17 @@ module.exports = class Master extends EventEmitter __define 'deregisterEvents', value: -> if @registered + # Remove all listeners from cluster instance do @removeAllListeners do cluster.removeAllListeners - do process.removeAllListeners + # Remove all listeners from process instance + for [ event, listener ] in @__listeners + process.removeListener event, listener + + # Reset state to the defaults @registered = no + @__listeners.length = 0 return this