mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Ensure that we correctly allocate worker ports. We were off by one before.
This commit is contained in:
parent
ba7e467ebd
commit
72000cc717
2 changed files with 8 additions and 4 deletions
|
@ -32,7 +32,7 @@ program
|
||||||
, Number
|
, Number
|
||||||
, 7400)
|
, 7400)
|
||||||
.option('--max-port <port>'
|
.option('--max-port <port>'
|
||||||
, 'maximum port number for worker use (total must be multiple of 3)'
|
, 'maximum port number for worker use'
|
||||||
, Number
|
, Number
|
||||||
, 7700)
|
, 7700)
|
||||||
.option('--public-ip <ip>'
|
.option('--public-ip <ip>'
|
||||||
|
|
|
@ -27,6 +27,10 @@ module.exports = function(options) {
|
||||||
}
|
}
|
||||||
var totalsTimer
|
var totalsTimer
|
||||||
|
|
||||||
|
// To make sure that we always bind the same type of service to the same
|
||||||
|
// port, we must ensure that we allocate ports in fixed groups.
|
||||||
|
var ports = options.ports.slice(0, -options.ports.length % 3)
|
||||||
|
|
||||||
// Information about total devices
|
// Information about total devices
|
||||||
var delayedTotals = (function() {
|
var delayedTotals = (function() {
|
||||||
function totals() {
|
function totals() {
|
||||||
|
@ -261,8 +265,8 @@ module.exports = function(options) {
|
||||||
|
|
||||||
// Spawn a device worker
|
// Spawn a device worker
|
||||||
function spawn() {
|
function spawn() {
|
||||||
var ports = options.ports.splice(0, 3)
|
var allocatedPorts = ports.splice(0, 3)
|
||||||
, proc = options.fork(device, ports)
|
, proc = options.fork(device, allocatedPorts)
|
||||||
, resolver = Promise.defer()
|
, resolver = Promise.defer()
|
||||||
|
|
||||||
function exitListener(code, signal) {
|
function exitListener(code, signal) {
|
||||||
|
@ -323,7 +327,7 @@ module.exports = function(options) {
|
||||||
proc.removeListener('message', messageListener)
|
proc.removeListener('message', messageListener)
|
||||||
|
|
||||||
// Return used ports to the main pool
|
// Return used ports to the main pool
|
||||||
Array.prototype.push.apply(options.ports, ports)
|
Array.prototype.push.apply(ports, allocatedPorts)
|
||||||
|
|
||||||
// Update lists
|
// Update lists
|
||||||
_.pull(lists.ready, device.id)
|
_.pull(lists.ready, device.id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue