cluster: remove deprecated property
PR-URL: https://github.com/nodejs/node/pull/13702 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
eaaec57332
commit
1fcb76e8f2
@ -451,40 +451,6 @@ if (cluster.isMaster) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### worker.suicide
|
|
||||||
<!-- YAML
|
|
||||||
added: v0.7.0
|
|
||||||
deprecated: v6.0.0
|
|
||||||
changes:
|
|
||||||
- version: v7.0.0
|
|
||||||
pr-url: https://github.com/nodejs/node/pull/3747
|
|
||||||
description: Accessing this property will now emit a deprecation warning.
|
|
||||||
-->
|
|
||||||
|
|
||||||
> Stability: 0 - Deprecated: Use [`worker.exitedAfterDisconnect`][] instead.
|
|
||||||
|
|
||||||
An alias to [`worker.exitedAfterDisconnect`][].
|
|
||||||
|
|
||||||
Set by calling `.kill()` or `.disconnect()`. Until then, it is `undefined`.
|
|
||||||
|
|
||||||
The boolean `worker.suicide` is used to distinguish between voluntary
|
|
||||||
and accidental exit, the master may choose not to respawn a worker based on
|
|
||||||
this value.
|
|
||||||
|
|
||||||
```js
|
|
||||||
cluster.on('exit', (worker, code, signal) => {
|
|
||||||
if (worker.suicide === true) {
|
|
||||||
console.log('Oh, it was just voluntary – no need to worry');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// kill worker
|
|
||||||
worker.kill();
|
|
||||||
```
|
|
||||||
|
|
||||||
This API only exists for backwards compatibility and will be removed in the
|
|
||||||
future.
|
|
||||||
|
|
||||||
## Event: 'disconnect'
|
## Event: 'disconnect'
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v0.7.9
|
added: v0.7.9
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const internalUtil = require('internal/util');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const defineProperty = Object.defineProperty;
|
|
||||||
const suicideDeprecationMessage =
|
|
||||||
'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.';
|
|
||||||
|
|
||||||
module.exports = Worker;
|
module.exports = Worker;
|
||||||
|
|
||||||
@ -20,16 +16,6 @@ function Worker(options) {
|
|||||||
|
|
||||||
this.exitedAfterDisconnect = undefined;
|
this.exitedAfterDisconnect = undefined;
|
||||||
|
|
||||||
defineProperty(this, 'suicide', {
|
|
||||||
get: internalUtil.deprecate(
|
|
||||||
() => this.exitedAfterDisconnect,
|
|
||||||
suicideDeprecationMessage, 'DEP0007'),
|
|
||||||
set: internalUtil.deprecate(
|
|
||||||
(val) => { this.exitedAfterDisconnect = val; },
|
|
||||||
suicideDeprecationMessage, 'DEP0007'),
|
|
||||||
enumerable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
this.state = options.state || 'none';
|
this.state = options.state || 'none';
|
||||||
this.id = options.id | 0;
|
this.id = options.id | 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user