mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 05:53:27 +02:00
Replace device:support:quit with util:lifecycle, which is usable by non-device processes too.
This commit is contained in:
@@ -3,12 +3,12 @@ var split = require('split')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
var devutil = require('../../../util/devutil')
|
||||
var lifecycle = require('../../../util/lifecycle')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
.dependency(require('../support/quit'))
|
||||
.dependency(require('../resources/remote'))
|
||||
.define(function(options, adb, quit, remote) {
|
||||
.define(function(options, adb, remote) {
|
||||
var log = logger.createLogger('device:plugins:stats')
|
||||
|
||||
var service = {
|
||||
@@ -24,33 +24,18 @@ module.exports = syrup.serial()
|
||||
, '--listen-stats', service.port
|
||||
])
|
||||
.then(function(out) {
|
||||
lifecycle.share('Stats remote shell', out)
|
||||
out.pipe(split())
|
||||
.on('data', function(chunk) {
|
||||
log.info('Remote says: "%s"', chunk)
|
||||
})
|
||||
.on('error', function(err) {
|
||||
log.fatal('Remote shell had an error', err.stack)
|
||||
quit.fatal()
|
||||
})
|
||||
.on('end', function() {
|
||||
log.fatal('Remote shell ended')
|
||||
quit.fatal()
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.then(function(conn) {
|
||||
conn.pipe(split())
|
||||
.on('error', function(err) {
|
||||
log.fatal('Remote had an error', err.stack)
|
||||
quit.fatal()
|
||||
})
|
||||
.on('end', function() {
|
||||
log.fatal('Remote ended')
|
||||
quit.fatal()
|
||||
})
|
||||
return lifecycle.share('Stats connection', conn)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user