mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
New rewrite of provider. By moving to promises we should no longer have issues with double-quits.
This commit is contained in:
parent
8a23b37deb
commit
adaf3da228
3 changed files with 232 additions and 270 deletions
|
@ -34,3 +34,28 @@ module.exports.fork = function() {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Export
|
||||
module.exports.gracefullyKill = function(proc, timeout) {
|
||||
function killer(signal) {
|
||||
var deferred = Promise.defer()
|
||||
|
||||
function onExit() {
|
||||
deferred.resolve()
|
||||
}
|
||||
|
||||
proc.once('exit', onExit)
|
||||
proc.kill(signal)
|
||||
|
||||
return deferred.promise.finally(function() {
|
||||
proc.removeListener('exit', onExit)
|
||||
})
|
||||
}
|
||||
|
||||
return killer('SIGTERM')
|
||||
.timeout(timeout)
|
||||
.catch(function() {
|
||||
return killer('SIGKILL')
|
||||
.timeout(timeout)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue