monitor/REST_handle.js
function (size) {

	size = size || 1;
	LOG.warn('trying to assign ' + size + ' new ports...', 'SR.Monitor');
	
	// find first available port
	var port = SR.Settings.PORT_APP_RANGE_START;
	var last_port = SR.Settings.PORT_APP_RANGE_END;

	// first port found
	var first_port = undefined;
	var results = [];
	
	while (port <= last_port) {
		
		if (l_ports.hasOwnProperty(port) === false || l_ports[port] === null) {
			// found a unique port
			if (!first_port)
				first_port = port;
			
			// mark the port as assigned
			l_ports[port] = first_port;
			results.push(port);
			
			LOG.warn('assigning port: ' + port, 'SR.Monitor');	
			
			if (--size === 0)
				break;
		}
		port++;
	}

	// no available ports found, or not enough ports found
	if (port > last_port)
		return 0;
	
	if (results.length > 1)
		return results;
	else
		return results[0];
}
function (size) {

	size = size || 1;
	LOG.warn('trying to assign ' + size + ' new ports...', 'SR.Monitor');
	
	// find first available port
	var port = SR.Settings.PORT_APP_RANGE_START;
	var last_port = SR.Settings.PORT_APP_RANGE_END;

	// first port found
	var first_port = undefined;
	var results = [];
	
	while (port <= last_port) {
		
		if (l_ports.hasOwnProperty(port) === false || l_ports[port] === null) {
			// found a unique port
			if (!first_port)
				first_port = port;
			
			// mark the port as assigned
			l_ports[port] = first_port;
			results.push(port);
			
			LOG.warn('assigning port: ' + port, 'SR.Monitor');	
			
			if (--size === 0)
				break;
		}
		port++;
	}

	// no available ports found, or not enough ports found
	if (port > last_port)
		return 0;
	
	if (results.length > 1)
		return results;
	else
		return results[0];
}
function ( size ) { size = size || 1 ; LOG . warn ( 'trying to assign ' + size + ' new ports...' , 'SR.Monitor' ) ; // find first available port var port = SR . Settings . PORT_APP_RANGE_START ; var last_port = SR . Settings . PORT_APP_RANGE_END ; // first port found var first_port = undefined ; var results = [ ] ; while ( port <= last_port ) { if ( l_ports . hasOwnProperty ( port ) === false || l_ports [ port ] === null ) { // found a unique port if ( ! first_port ) first_port = port ; // mark the port as assigned l_ports [ port ] = first_port ; results . push ( port ) ; LOG . warn ( 'assigning port: ' + port , 'SR.Monitor' ) ; if ( -- size === 0 ) break ; } port ++ ; } // no available ports found, or not enough ports found if ( port > last_port ) return 0 ; if ( results . length > 1 ) return results ; else return results [ 0 ] ; }
assign a unique application port
assign a unique application port