mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Don't listen to 'end' on proxy server.
This commit is contained in:
parent
45f7db1728
commit
e0b4b3b40f
2 changed files with 22 additions and 10 deletions
|
@ -2,6 +2,7 @@ var Promise = require('bluebird')
|
|||
|
||||
var logger = require('./logger')
|
||||
var log = logger.createLogger('util:lifecycle')
|
||||
var _ = require('lodash')
|
||||
|
||||
function Lifecycle() {
|
||||
this.observers = []
|
||||
|
@ -9,16 +10,25 @@ function Lifecycle() {
|
|||
process.on('SIGTERM', this.graceful.bind(this))
|
||||
}
|
||||
|
||||
Lifecycle.prototype.share = function(name, emitter) {
|
||||
emitter.on('end', function() {
|
||||
log.fatal('%s ended; we shall share its fate', name)
|
||||
this.fatal()
|
||||
}.bind(this))
|
||||
Lifecycle.prototype.share = function(name, emitter, options) {
|
||||
_.defaults(options, {
|
||||
end: true
|
||||
, error: true
|
||||
})
|
||||
|
||||
emitter.on('error', function(err) {
|
||||
log.fatal('%s had an error', name, err.stack)
|
||||
this.fatal()
|
||||
}.bind(this))
|
||||
if (options.end) {
|
||||
emitter.on('end', function() {
|
||||
log.fatal('%s ended; we shall share its fate', name)
|
||||
this.fatal()
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
if (options.error) {
|
||||
emitter.on('error', function(err) {
|
||||
log.fatal('%s had an error', name, err.stack)
|
||||
this.fatal()
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
return emitter
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue