mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Read minicap pid from shell output. Should be more reliable for quick restarts.
This commit is contained in:
parent
76eb1b077a
commit
5a77d300dc
1 changed files with 28 additions and 2 deletions
|
@ -34,6 +34,7 @@ module.exports = syrup.serial()
|
|||
this.desiredState = new StateQueue()
|
||||
this.output = null
|
||||
this.socket = null
|
||||
this.pid = -1
|
||||
this.banner = null
|
||||
this.parser = null
|
||||
this.frameConfig = config
|
||||
|
@ -77,6 +78,9 @@ module.exports = syrup.serial()
|
|||
.on('unexpectedEnd', this._outputEnded.bind(this))
|
||||
return this._readOutput(this.output.stream)
|
||||
})
|
||||
.then(function() {
|
||||
return this._waitForPid()
|
||||
})
|
||||
.then(function() {
|
||||
return this._connectService()
|
||||
})
|
||||
|
@ -242,8 +246,29 @@ module.exports = syrup.serial()
|
|||
return lifecycle.fatal()
|
||||
}
|
||||
|
||||
var match
|
||||
if ((match = /^PID: (\d+)$/.exec(line))) {
|
||||
this.pid = +match[1]
|
||||
this.emit('pid', this.pid)
|
||||
}
|
||||
|
||||
log.info('minicap says: "%s"', line)
|
||||
})
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
FrameProducer.prototype._waitForPid = function() {
|
||||
if (this.pid > 0) {
|
||||
return Promise.resolve(this.pid)
|
||||
}
|
||||
|
||||
var pidListener
|
||||
return new Promise(function(resolve/*, reject*/) {
|
||||
this.on('pid', pidListener = resolve)
|
||||
}.bind(this)).bind(this)
|
||||
.timeout(2000)
|
||||
.finally(function() {
|
||||
this.removeListener('pid', pidListener)
|
||||
})
|
||||
}
|
||||
|
||||
FrameProducer.prototype._connectService = function() {
|
||||
|
@ -288,6 +313,7 @@ module.exports = syrup.serial()
|
|||
.finally(function() {
|
||||
this.output = null
|
||||
this.socket = null
|
||||
this.pid = -1
|
||||
this.banner = null
|
||||
this.parser = null
|
||||
})
|
||||
|
@ -323,7 +349,7 @@ module.exports = syrup.serial()
|
|||
return Promise.resolve(true)
|
||||
}
|
||||
|
||||
var pid = this.banner ? this.banner.pid : -1
|
||||
var pid = this.pid
|
||||
|
||||
function kill(signal) {
|
||||
if (pid <= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue