mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 16:43:26 +02:00
In-memory reaper. TtlSet needs tests.
This commit is contained in:
@@ -16,6 +16,7 @@ module.exports = function(options) {
|
||||
var log = logger.createLogger('device')
|
||||
log.info('Preparing device')
|
||||
return syrup.serial()
|
||||
.dependency(require('./plugins/heartbeat'))
|
||||
.dependency(require('./plugins/solo'))
|
||||
.dependency(require('./plugins/screen/stream'))
|
||||
.dependency(require('./plugins/screen/capture'))
|
||||
@@ -38,7 +39,7 @@ module.exports = function(options) {
|
||||
.dependency(require('./plugins/ringer'))
|
||||
.dependency(require('./plugins/wifi'))
|
||||
.dependency(require('./plugins/sd'))
|
||||
.define(function(options, solo) {
|
||||
.define(function(options, heartbeat, solo) {
|
||||
if (process.send) {
|
||||
// Only if we have a parent process
|
||||
process.send('ready')
|
||||
|
||||
24
lib/units/device/plugins/heartbeat.js
Normal file
24
lib/units/device/plugins/heartbeat.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var syrup = require('stf-syrup')
|
||||
|
||||
var lifecycle = require('../../../util/lifecycle')
|
||||
var wire = require('../../../wire')
|
||||
var wireutil = require('../../../wire/util')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/push'))
|
||||
.define(function(options, push) {
|
||||
function beat() {
|
||||
push.send([
|
||||
wireutil.global
|
||||
, wireutil.envelope(new wire.DeviceHeartbeatMessage(
|
||||
options.serial
|
||||
))
|
||||
])
|
||||
}
|
||||
|
||||
var timer = setInterval(beat, options.heartbeatInterval)
|
||||
|
||||
lifecycle.observe(function() {
|
||||
clearInterval(timer)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user