mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-25 18:25:15 +02:00
Send heartbeats from the provider. This keeps unauthorized and offline devices present as well, which is what we want. This also greatly reduces the number of queries to rethinkdb.
This commit is contained in:
@@ -17,7 +17,6 @@ module.exports = function(options) {
|
||||
log.info('Preparing device')
|
||||
return syrup.serial()
|
||||
.dependency(require('./device/plugins/solo'))
|
||||
.dependency(require('./device/plugins/heartbeat'))
|
||||
.dependency(require('./device/plugins/display'))
|
||||
.dependency(require('./device/plugins/screenshot'))
|
||||
.dependency(require('./device/plugins/http'))
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
var syrup = require('syrup')
|
||||
|
||||
var wire = require('../../../wire')
|
||||
var wireutil = require('../../../wire/util')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/push'))
|
||||
.define(function(options, push) {
|
||||
function heartbeat() {
|
||||
push.send([
|
||||
wireutil.heartbeat
|
||||
, wireutil.envelope(new wire.DeviceHeartbeatMessage(
|
||||
options.serial
|
||||
))
|
||||
])
|
||||
setTimeout(heartbeat, options.heartbeatInterval)
|
||||
}
|
||||
|
||||
heartbeat()
|
||||
})
|
||||
@@ -33,6 +33,10 @@ module.exports = function(options) {
|
||||
})
|
||||
|
||||
devDealer.on('message', wirerouter()
|
||||
// Provider messages
|
||||
.on(wire.ProviderHeartbeatMessage, function(channel, message) {
|
||||
dbapi.updateProviderHeartbeat(message.channel)
|
||||
})
|
||||
// Initial device message
|
||||
.on(wire.DevicePresentMessage, function(channel, message, data) {
|
||||
dbapi.saveDevice(message.serial, message)
|
||||
@@ -66,9 +70,6 @@ module.exports = function(options) {
|
||||
})
|
||||
})
|
||||
// Worker messages
|
||||
.on(wire.DeviceHeartbeatMessage, function(channel, message) {
|
||||
dbapi.updateDeviceHeartbeat(message.serial)
|
||||
})
|
||||
.on(wire.JoinGroupMessage, function(channel, message, data) {
|
||||
dbapi.setDeviceOwner(message.serial, message.owner)
|
||||
appDealer.send([channel, data])
|
||||
|
||||
@@ -362,6 +362,19 @@ module.exports = function(options) {
|
||||
lifecycle.share('Tracker', tracker)
|
||||
})
|
||||
|
||||
// This keeps the devices "present" in the database. It relies on the
|
||||
// provider channel changing on every run so that we never match old
|
||||
// devices.
|
||||
;(function heartbeat() {
|
||||
push.send([
|
||||
wireutil.heartbeat
|
||||
, wireutil.envelope(new wire.ProviderHeartbeatMessage(
|
||||
solo
|
||||
))
|
||||
])
|
||||
setTimeout(heartbeat, options.heartbeatInterval)
|
||||
})()
|
||||
|
||||
lifecycle.observe(function() {
|
||||
clearTimeout(totalsTimer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user