mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 15:55:16 +02:00
Log number of provided devices.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user