1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Don't try to restart if we're stopping.

This commit is contained in:
Simo Kinnunen 2014-04-11 10:24:39 +09:00
parent e10a58c881
commit e4b701df5d

View file

@ -104,6 +104,7 @@ module.exports = function(options) {
log.info('Found device "%s" (%s)', device.id, device.type)
var privateTracker = new events.EventEmitter()
, willStop = false
, timer
, worker
@ -209,9 +210,11 @@ module.exports = function(options) {
switch (device.type) {
case 'device':
case 'emulator':
willStop = false
timer = setTimeout(work, 100)
break
default:
willStop = true
timer = setTimeout(stop, 100)
break
}
@ -230,16 +233,18 @@ module.exports = function(options) {
worker = null
})
.catch(procutil.ExitError, function(err) {
log.error(
'Device worker "%s" died with code %s'
, device.id
, err.code
)
log.info('Restarting device worker "%s"', device.id)
return Promise.delay(500)
.then(function() {
return work()
})
if (!willStop) {
log.error(
'Device worker "%s" died with code %s'
, device.id
, err.code
)
log.info('Restarting device worker "%s"', device.id)
return Promise.delay(500)
.then(function() {
return work()
})
}
})
}