mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Log number of provided devices.
This commit is contained in:
parent
3e3b98891f
commit
f37e1d8adb
1 changed files with 13 additions and 0 deletions
|
@ -14,6 +14,7 @@ module.exports = function(options) {
|
|||
var client = Promise.promisifyAll(adb.createClient())
|
||||
var workers = Object.create(null)
|
||||
var tracker = new events.EventEmitter()
|
||||
var counter = 0
|
||||
|
||||
// Output
|
||||
var push = zmq.socket('push')
|
||||
|
@ -102,6 +103,7 @@ module.exports = function(options) {
|
|||
function exitListener(code, signal) {
|
||||
var data = workers[device.id]
|
||||
delete workers[device.id]
|
||||
counter -= 1
|
||||
switch (code) {
|
||||
case 0:
|
||||
log.info('Device worker "%s" stopped cleanly', device.id)
|
||||
|
@ -160,6 +162,9 @@ module.exports = function(options) {
|
|||
proc.removeListener('exit', exitListener)
|
||||
}
|
||||
}
|
||||
|
||||
counter += 1
|
||||
boast()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -201,6 +206,8 @@ module.exports = function(options) {
|
|||
function onExit() {
|
||||
delete workers[id]
|
||||
log.info('Gracefully killed device worker "%s"', id)
|
||||
counter -= 1
|
||||
boast()
|
||||
deferred.resolve()
|
||||
}
|
||||
|
||||
|
@ -222,6 +229,8 @@ module.exports = function(options) {
|
|||
function onExit() {
|
||||
delete workers[id]
|
||||
log.warn('Force killed device worker "%s"', id)
|
||||
counter -= 1
|
||||
boast()
|
||||
deferred.resolve()
|
||||
}
|
||||
|
||||
|
@ -253,6 +262,10 @@ module.exports = function(options) {
|
|||
})
|
||||
}
|
||||
|
||||
function boast() {
|
||||
log.info('Providing %d device(s)', counter)
|
||||
}
|
||||
|
||||
process.on('SIGINT', function(e) {
|
||||
log.info('Received SIGINT')
|
||||
gracefullyExit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue