1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Ensure that we correctly allocate worker ports. We were off by one before.

This commit is contained in:
Simo Kinnunen 2014-06-09 19:00:26 +09:00
parent ba7e467ebd
commit 72000cc717
2 changed files with 8 additions and 4 deletions

View file

@ -32,7 +32,7 @@ program
, Number
, 7400)
.option('--max-port <port>'
, 'maximum port number for worker use (total must be multiple of 3)'
, 'maximum port number for worker use'
, Number
, 7700)
.option('--public-ip <ip>'

View file

@ -27,6 +27,10 @@ module.exports = function(options) {
}
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
var delayedTotals = (function() {
function totals() {
@ -261,8 +265,8 @@ module.exports = function(options) {
// Spawn a device worker
function spawn() {
var ports = options.ports.splice(0, 3)
, proc = options.fork(device, ports)
var allocatedPorts = ports.splice(0, 3)
, proc = options.fork(device, allocatedPorts)
, resolver = Promise.defer()
function exitListener(code, signal) {
@ -323,7 +327,7 @@ module.exports = function(options) {
proc.removeListener('message', messageListener)
// Return used ports to the main pool
Array.prototype.push.apply(options.ports, ports)
Array.prototype.push.apply(ports, allocatedPorts)
// Update lists
_.pull(lists.ready, device.id)