mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Give open device ports their own options. Preparing for future refactor.
This commit is contained in:
parent
b3b538c561
commit
105795bec7
4 changed files with 19 additions and 11 deletions
22
lib/cli.js
22
lib/cli.js
|
@ -94,7 +94,8 @@ program
|
|||
, '--provider', options.name
|
||||
, '--connect-sub', options.connectSub.join(',')
|
||||
, '--connect-push', options.connectPush.join(',')
|
||||
, '--ports', ports.join(',')
|
||||
, '--screen-port', ports.shift()
|
||||
, '--connect-port', ports.shift()
|
||||
, '--public-ip', options.publicIp
|
||||
, '--group-timeout', options.groupTimeout
|
||||
, '--storage-url', options.storageUrl
|
||||
|
@ -126,9 +127,12 @@ program
|
|||
.option('-p, --connect-push <endpoint>'
|
||||
, 'push endpoint'
|
||||
, cliutil.list)
|
||||
.option('--ports <ports>'
|
||||
, 'ports allocated to worker'
|
||||
, cliutil.list)
|
||||
.option('--screen-port <port>'
|
||||
, 'port allocated to the screen websocket'
|
||||
, Number)
|
||||
.option('--connect-port <port>'
|
||||
, 'port allocated to adb connect'
|
||||
, Number)
|
||||
.option('--public-ip <ip>'
|
||||
, 'public ip for global access'
|
||||
, String
|
||||
|
@ -164,8 +168,11 @@ program
|
|||
if (!options.provider) {
|
||||
this.missingArgument('--provider')
|
||||
}
|
||||
if (!options.ports) {
|
||||
this.missingArgument('--ports')
|
||||
if (!options.screenPort) {
|
||||
this.missingArgument('--screen-port')
|
||||
}
|
||||
if (!options.connectPort) {
|
||||
this.missingArgument('--connect-port')
|
||||
}
|
||||
if (!options.storageUrl) {
|
||||
this.missingArgument('--storage-url')
|
||||
|
@ -174,7 +181,6 @@ program
|
|||
require('./units/device')({
|
||||
serial: serial
|
||||
, provider: options.provider
|
||||
, ports: options.ports
|
||||
, publicIp: options.publicIp
|
||||
, endpoints: {
|
||||
sub: options.connectSub
|
||||
|
@ -186,6 +192,8 @@ program
|
|||
, adbPort: options.adbPort
|
||||
, disableScreenPublicProxy: !!options.disableScreenPublicProxy
|
||||
, screenWsUrlPattern: options.screenWsUrlPattern
|
||||
, screenPort: options.screenPort
|
||||
, connectPort: options.connectPort
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = syrup.serial()
|
|||
, plugin = Object.create(null)
|
||||
, activeServer = null
|
||||
|
||||
plugin.port = options.ports.pop()
|
||||
plugin.port = options.connectPort
|
||||
plugin.url = util.format('%s:%s', options.publicIp, plugin.port)
|
||||
|
||||
plugin.start = function() {
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = syrup.serial()
|
|||
var plugin = Object.create(null)
|
||||
|
||||
plugin.devicePort = 9002
|
||||
plugin.publicPort = options.ports.pop()
|
||||
plugin.publicPort = options.screenPort
|
||||
plugin.publicUrl = _.template(options.screenWsUrlPattern)({
|
||||
publicIp: options.publicIp
|
||||
, publicPort: plugin.publicPort
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = function(options) {
|
|||
// port, we must ensure that we allocate ports in fixed groups.
|
||||
var ports = options.ports.slice(
|
||||
0
|
||||
, options.ports.length - options.ports.length % 4
|
||||
, options.ports.length - options.ports.length % 2
|
||||
)
|
||||
|
||||
// Information about total devices
|
||||
|
@ -303,7 +303,7 @@ module.exports = function(options) {
|
|||
|
||||
// Spawn a device worker
|
||||
function spawn() {
|
||||
var allocatedPorts = ports.splice(0, 4)
|
||||
var allocatedPorts = ports.splice(0, 2)
|
||||
, proc = options.fork(device, allocatedPorts)
|
||||
, resolver = Promise.defer()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue