mirror of
https://github.com/openstf/stf
synced 2025-10-03 17:59:28 +02:00
Allocate two ports to each worker.
This commit is contained in:
parent
e0426d01be
commit
c45c081c6f
3 changed files with 43 additions and 12 deletions
19
lib/cli.js
19
lib/cli.js
|
@ -31,6 +31,14 @@ program
|
|||
, 'restart worker only if it stays alive for longer than this'
|
||||
, Number
|
||||
, 10000)
|
||||
.option('--min-port <port>'
|
||||
, 'minimum port number for worker use'
|
||||
, Number
|
||||
, 7400)
|
||||
.option('--max-port <port>'
|
||||
, 'maximum port number for worker use'
|
||||
, Number
|
||||
, 7800)
|
||||
.action(function() {
|
||||
var serials = cliutil.allUnknownArgs(arguments)
|
||||
, options = cliutil.lastArg(arguments)
|
||||
|
@ -47,16 +55,18 @@ program
|
|||
, restartThreshold: options.restartThreshold
|
||||
, restartTimeout: 1000
|
||||
, killTimeout: 10000
|
||||
, ports: cliutil.range(options.minPort, options.maxPort)
|
||||
, filter: function(device) {
|
||||
return serials.length === 0 || serials.indexOf(device.id) !== -1
|
||||
}
|
||||
, fork: function(device) {
|
||||
, fork: function(device, ports) {
|
||||
var fork = require('child_process').fork
|
||||
return fork(__filename, [
|
||||
'device', device.id
|
||||
, '--provider', options.name
|
||||
, '--connect-sub', options.connectSub.join(',')
|
||||
, '--connect-push', options.connectPush.join(',')
|
||||
, '--ports', ports.join(',')
|
||||
])
|
||||
}
|
||||
, endpoints: {
|
||||
|
@ -78,6 +88,9 @@ program
|
|||
.option('-p, --connect-push <endpoint>'
|
||||
, 'push endpoint'
|
||||
, cliutil.list)
|
||||
.option('--ports <ports>'
|
||||
, 'ports allocated to worker'
|
||||
, cliutil.list)
|
||||
.action(function(serial, options) {
|
||||
if (!options.connectSub) {
|
||||
this.missingArgument('--connect-sub')
|
||||
|
@ -88,10 +101,14 @@ program
|
|||
if (!options.provider) {
|
||||
this.missingArgument('--provider')
|
||||
}
|
||||
if (!options.provider) {
|
||||
this.missingArgument('--ports')
|
||||
}
|
||||
|
||||
require('./roles/device')({
|
||||
serial: serial
|
||||
, provider: options.provider
|
||||
, ports: options.ports
|
||||
, endpoints: {
|
||||
sub: options.connectSub
|
||||
, push: options.connectPush
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue