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

Detect if we kill device worker before it becomes operational.

This commit is contained in:
Simo Kinnunen 2014-01-28 23:21:39 +09:00
parent f056e0d2ca
commit a4725fe71c

View file

@ -86,20 +86,26 @@ module.exports = function(options) {
proc.on('exit', function(code, signal) { proc.on('exit', function(code, signal) {
var data = workers[device.id] var data = workers[device.id]
delete workers[device.id] delete workers[device.id]
if (code === 0) { switch (code) {
log.info('Device worker "%s" stopped cleanly', device.id) case 0:
} log.info('Device worker "%s" stopped cleanly', device.id)
else { break
log.error('Device worker "%s" had a dirty exit (code %d)', case 143: // SIGTERM
device.id, code) log.warn('Device worker "%s" was killed before becoming operational'
if (Date.now() - data.started < 10000) { , device.id)
log.error('Device worker "%s" failed within 10 seconds of startup,' + break
' will not attempt to restart', device.id) default:
} log.error('Device worker "%s" had a dirty exit (code %d)',
else { device.id, code)
log.info('Restarting worker of "%s"', device.id) if (Date.now() - data.started < 10000) {
maybeConnect(device) log.error('Device worker "%s" failed within 10 seconds of startup,' +
} ' will not attempt to restart', device.id)
}
else {
log.info('Restarting worker of "%s"', device.id)
maybeConnect(device)
}
break
} }
}) })
workers[device.id] = { workers[device.id] = {