mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 14:53:24 +02:00
Reaper decides if a device is present or not. Allows devices to "come back to life" if they start beating again.
This commit is contained in:
@@ -56,7 +56,17 @@ module.exports = function(options) {
|
||||
lifecycle.fatal()
|
||||
})
|
||||
|
||||
ttlset.on('timeout', function(serial) {
|
||||
ttlset.on('insert', function(serial) {
|
||||
log.info('Device "%s" is present', serial)
|
||||
push.send([
|
||||
wireutil.global
|
||||
, wireutil.envelope(new wire.DevicePresentMessage(
|
||||
serial
|
||||
))
|
||||
])
|
||||
})
|
||||
|
||||
ttlset.on('drop', function(serial) {
|
||||
log.info('Reaping device "%s" due to heartbeat timeout', serial)
|
||||
push.send([
|
||||
wireutil.global
|
||||
@@ -73,7 +83,7 @@ module.exports = function(options) {
|
||||
.then(function(list) {
|
||||
var now = Date.now()
|
||||
list.forEach(function(device) {
|
||||
ttlset.bump(device.serial, now)
|
||||
ttlset.bump(device.serial, now, TtlSet.SILENT)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -81,14 +91,14 @@ module.exports = function(options) {
|
||||
|
||||
function listenToChanges() {
|
||||
sub.on('message', wirerouter()
|
||||
.on(wire.DevicePresentMessage, function(channel, message) {
|
||||
.on(wire.DeviceIntroductionMessage, function(channel, message) {
|
||||
ttlset.bump(message.serial, Date.now())
|
||||
})
|
||||
.on(wire.DeviceHeartbeatMessage, function(channel, message) {
|
||||
ttlset.bump(message.serial, Date.now())
|
||||
})
|
||||
.on(wire.DeviceAbsentMessage, function(channel, message) {
|
||||
ttlset.drop(message.serial)
|
||||
ttlset.drop(message.serial, TtlSet.SILENT)
|
||||
})
|
||||
.handler())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user