mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 17:53:32 +02:00
Start HTTP API on device.
This commit is contained in:
@@ -72,6 +72,40 @@ module.exports = function(options) {
|
||||
})
|
||||
}))
|
||||
})
|
||||
.then(function() {
|
||||
log.info('Checking if any processes from a previous run are still up')
|
||||
return devutil.killProcsByBin(adb, options.serial, vendor.bin.dest)
|
||||
})
|
||||
.then(function() {
|
||||
var port = 2870
|
||||
return adb.openTcpAsync(options.serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
throw new Error(util.format('Old connection still lives on port %d', port))
|
||||
})
|
||||
.catch(function(err) {
|
||||
if (err.message === 'closed') {
|
||||
return adb.shellAsync(options.serial, [
|
||||
vendor.bin.dest
|
||||
, '--lib', vendor.lib.dest
|
||||
, '--listen-http', port
|
||||
])
|
||||
.then(function(out) {
|
||||
out.pipe(require('split')())
|
||||
.on('data', function(chunk) {
|
||||
log.info('remote: "%s"', chunk)
|
||||
})
|
||||
.on('end', function() {
|
||||
log.fatal('remote: Connection closed')
|
||||
selfDestruct()
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
})
|
||||
.done(function() {
|
||||
log.info('Ready for instructions')
|
||||
poke()
|
||||
@@ -163,6 +197,10 @@ module.exports = function(options) {
|
||||
wireutil.makeDevicePokeMessage(options.serial, solo)])
|
||||
}
|
||||
|
||||
function selfDestruct() {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
function gracefullyExit() {
|
||||
log.info('Bye')
|
||||
process.exit(0)
|
||||
|
||||
Reference in New Issue
Block a user