1
0
Fork 0
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:
Simo Kinnunen 2014-01-30 14:33:51 +09:00
parent 3e3b98891f
commit f37e1d8adb

View file

@ -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()