From b4b1e8b42f8d039cbfb8eec9460c4179743e3aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cervi=C3=B1o?= Date: Fri, 22 Sep 2017 10:39:59 +0200 Subject: [PATCH] Update global to lower case (#1039) --- erizo_controller/common/amqper.js | 18 +-- erizo_controller/common/logger.js | 4 +- erizo_controller/erizoAgent/erizoAgent.js | 78 +++++----- .../erizoController/ecCloudHandler.js | 4 +- .../erizoController/erizoController.js | 145 +++++++++--------- erizo_controller/erizoJS/erizoJS.js | 54 +++---- erizo_controller/erizoJS/erizoJSController.js | 20 +-- erizo_controller/erizoJS/models/Publisher.js | 22 +-- .../test/erizoAgent/erizoAgent.js | 12 +- .../test/erizoController/ecCloudHandler.js | 6 +- .../test/erizoController/erizoController.js | 8 +- .../test/erizoController/roomController.js | 4 +- .../test/erizoJS/erizoJSController.js | 8 +- spine/nativeClient.js | 28 ++-- 14 files changed, 205 insertions(+), 206 deletions(-) diff --git a/erizo_controller/common/amqper.js b/erizo_controller/common/amqper.js index 0cea445f1c..ab03cb12ed 100644 --- a/erizo_controller/common/amqper.js +++ b/erizo_controller/common/amqper.js @@ -6,9 +6,9 @@ var logger = require('./logger').logger; var log = logger.getLogger('AMQPER'); // Configuration default values -GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; -GLOBAL.config.rabbit.host = GLOBAL.config.rabbit.host || 'localhost'; -GLOBAL.config.rabbit.port = GLOBAL.config.rabbit.port || 5672; +global.config.rabbit = global.config.rabbit || {}; +global.config.rabbit.host = global.config.rabbit.host || 'localhost'; +global.config.rabbit.port = global.config.rabbit.port || 5672; var TIMEOUT = 5000; @@ -22,15 +22,15 @@ var connection, rpcExc, broadcastExc, clientQueue; var addr = {}; var rpcPublic = {}; -if (GLOBAL.config.rabbit.url !== undefined) { - addr.url = GLOBAL.config.rabbit.url; +if (global.config.rabbit.url !== undefined) { + addr.url = global.config.rabbit.url; } else { - addr.host = GLOBAL.config.rabbit.host; - addr.port = GLOBAL.config.rabbit.port; + addr.host = global.config.rabbit.host; + addr.port = global.config.rabbit.port; } -if(GLOBAL.config.rabbit.heartbeat !==undefined){ - addr.heartbeat = GLOBAL.config.rabbit.heartbeat; +if(global.config.rabbit.heartbeat !==undefined){ + addr.heartbeat = global.config.rabbit.heartbeat; } exports.setPublicRPC = function(methods) { diff --git a/erizo_controller/common/logger.js b/erizo_controller/common/logger.js index db8963da47..fc231005e6 100644 --- a/erizo_controller/common/logger.js +++ b/erizo_controller/common/logger.js @@ -1,9 +1,9 @@ 'use strict'; var log4js = require('log4js'); -GLOBAL.config.logger = GLOBAL.config.logger || {}; +global.config.logger = global.config.logger || {}; -var logFile = GLOBAL.config.logger.configFile || '../log4js_configuration.json'; +var logFile = global.config.logger.configFile || '../log4js_configuration.json'; var logJsonReplacer = function (key, value){ diff --git a/erizo_controller/erizoAgent/erizoAgent.js b/erizo_controller/erizoAgent/erizoAgent.js index ed255b80d0..11a9908eca 100644 --- a/erizo_controller/erizoAgent/erizoAgent.js +++ b/erizo_controller/erizoAgent/erizoAgent.js @@ -7,20 +7,20 @@ var spawn = require('child_process').spawn; var config = require('./../../licode_config'); // Configuration default values -GLOBAL.config = config || {}; -GLOBAL.config.erizoAgent = GLOBAL.config.erizoAgent || {}; -GLOBAL.config.erizoAgent.maxProcesses = GLOBAL.config.erizoAgent.maxProcesses || 1; -GLOBAL.config.erizoAgent.prerunProcesses = - GLOBAL.config.erizoAgent.prerunProcesses === undefined ? - 1 : GLOBAL.config.erizoAgent.prerunProcesses; -GLOBAL.config.erizoAgent.publicIP = GLOBAL.config.erizoAgent.publicIP || ''; -GLOBAL.config.erizoAgent.instanceLogDir = GLOBAL.config.erizoAgent.instanceLogDir || '.'; -GLOBAL.config.erizoAgent.useIndividualLogFiles = - GLOBAL.config.erizoAgent.useIndividualLogFiles|| false; - -GLOBAL.config.erizoAgent.launchDebugErizoJS = GLOBAL.config.erizoAgent.launchDebugErizoJS || false; - -var BINDED_INTERFACE_NAME = GLOBAL.config.erizoAgent.networkInterface; +global.config = config || {}; +global.config.erizoAgent = global.config.erizoAgent || {}; +global.config.erizoAgent.maxProcesses = global.config.erizoAgent.maxProcesses || 1; +global.config.erizoAgent.prerunProcesses = + global.config.erizoAgent.prerunProcesses === undefined ? + 1 : global.config.erizoAgent.prerunProcesses; +global.config.erizoAgent.publicIP = global.config.erizoAgent.publicIP || ''; +global.config.erizoAgent.instanceLogDir = global.config.erizoAgent.instanceLogDir || '.'; +global.config.erizoAgent.useIndividualLogFiles = + global.config.erizoAgent.useIndividualLogFiles|| false; + +global.config.erizoAgent.launchDebugErizoJS = global.config.erizoAgent.launchDebugErizoJS || false; + +var BINDED_INTERFACE_NAME = global.config.erizoAgent.networkInterface; const LAUNCH_SCRIPT = './launch.sh'; // Parse command line arguments @@ -58,37 +58,37 @@ for (var prop in opt.options) { process.exit(0); break; case 'rabbit-host': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.host = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.host = value; break; case 'rabbit-port': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.port = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.port = value; break; case 'rabbit-heartbeat': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.heartbeat = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.heartbeat = value; break; case 'max-processes': - GLOBAL.config.erizoAgent = GLOBAL.config.erizoAgent || {}; - GLOBAL.config.erizoAgent.maxProcesses = value; + global.config.erizoAgent = global.config.erizoAgent || {}; + global.config.erizoAgent.maxProcesses = value; break; case 'prerun-processes': - GLOBAL.config.erizoAgent = GLOBAL.config.erizoAgent || {}; - GLOBAL.config.erizoAgent.prerunProcesses = value; + global.config.erizoAgent = global.config.erizoAgent || {}; + global.config.erizoAgent.prerunProcesses = value; break; case 'individual-logs': - GLOBAL.config.erizoAgent = GLOBAL.config.erizoAgent || {}; - GLOBAL.config.erizoAgent.useIndividualLogFiles = true; + global.config.erizoAgent = global.config.erizoAgent || {}; + global.config.erizoAgent.useIndividualLogFiles = true; break; case 'metadata': metadata = JSON.parse(value); break; case 'debug': - GLOBAL.config.erizoAgent.launchDebugErizoJS = true; + global.config.erizoAgent.launchDebugErizoJS = true; break; default: - GLOBAL.config.erizoAgent[prop] = value; + global.config.erizoAgent[prop] = value; break; } } @@ -123,8 +123,8 @@ var myErizoAgentId = guid(); var launchErizoJS; var fillErizos = function () { - if (erizos.length + idleErizos.length < GLOBAL.config.erizoAgent.maxProcesses) { - if (idleErizos.length < GLOBAL.config.erizoAgent.prerunProcesses) { + if (erizos.length + idleErizos.length < global.config.erizoAgent.maxProcesses) { + if (idleErizos.length < global.config.erizoAgent.prerunProcesses) { launchErizoJS(); fillErizos(); } @@ -137,13 +137,13 @@ launchErizoJS = function() { var fs = require('fs'); var erizoProcess, out, err; const erizoLaunchOptions = ['./../erizoJS/erizoJS.js', id, privateIP, publicIP]; - if (GLOBAL.config.erizoAgent.launchDebugErizoJS) { + if (global.config.erizoAgent.launchDebugErizoJS) { erizoLaunchOptions.push('-d'); } - if (GLOBAL.config.erizoAgent.useIndividualLogFiles){ - out = fs.openSync(GLOBAL.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a'); - err = fs.openSync(GLOBAL.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a'); + if (global.config.erizoAgent.useIndividualLogFiles){ + out = fs.openSync(global.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a'); + err = fs.openSync(global.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a'); erizoProcess = spawn(LAUNCH_SCRIPT, erizoLaunchOptions, { detached: true, stdio: [ 'ignore', out, err ] }); }else{ @@ -220,7 +220,7 @@ var getErizo = function () { var erizoId = idleErizos.shift(); if (!erizoId) { - if (erizos.length < GLOBAL.config.erizoAgent.maxProcesses) { + if (erizos.length < global.config.erizoAgent.maxProcesses) { launchErizoJS(); return getErizo(); } else { @@ -261,8 +261,8 @@ var api = { for (k in interfaces) { if (interfaces.hasOwnProperty(k)) { - if (!GLOBAL.config.erizoAgent.networkinterface || - GLOBAL.config.erizoAgent.networkinterface === k) { + if (!global.config.erizoAgent.networkinterface || + global.config.erizoAgent.networkinterface === k) { for (k2 in interfaces[k]) { if (interfaces[k].hasOwnProperty(k2)) { address = interfaces[k][k2]; @@ -279,7 +279,7 @@ for (k in interfaces) { privateIP = addresses[0]; -if (GLOBAL.config.erizoAgent.publicIP === '' || GLOBAL.config.erizoAgent.publicIP === undefined) { +if (global.config.erizoAgent.publicIP === '' || global.config.erizoAgent.publicIP === undefined) { publicIP = addresses[0]; if (global.config.cloudProvider.name === 'amazon') { @@ -301,7 +301,7 @@ if (GLOBAL.config.erizoAgent.publicIP === '' || GLOBAL.config.erizoAgent.publicI fillErizos(); } } else { - publicIP = GLOBAL.config.erizoAgent.publicIP; + publicIP = global.config.erizoAgent.publicIP; fillErizos(); } diff --git a/erizo_controller/erizoController/ecCloudHandler.js b/erizo_controller/erizoController/ecCloudHandler.js index 580309ab51..7fefa6dae3 100644 --- a/erizo_controller/erizoController/ecCloudHandler.js +++ b/erizo_controller/erizoController/ecCloudHandler.js @@ -56,9 +56,9 @@ exports.EcCloudHandler = function (spec) { var getErizoAgent; - if (GLOBAL.config.erizoController.cloudHandlerPolicy) { + if (global.config.erizoController.cloudHandlerPolicy) { getErizoAgent = require('./ch_policies/' + - GLOBAL.config.erizoController.cloudHandlerPolicy).getErizoAgent; + global.config.erizoController.cloudHandlerPolicy).getErizoAgent; } var tryAgain = function (count, agentId, callback) { diff --git a/erizo_controller/erizoController/erizoController.js b/erizo_controller/erizoController/erizoController.js index ba782ac782..6bd23de2c1 100644 --- a/erizo_controller/erizoController/erizoController.js +++ b/erizo_controller/erizoController/erizoController.js @@ -8,36 +8,36 @@ var Permission = require('./permission'); var Getopt = require('node-getopt'); // Configuration default values -GLOBAL.config = config || {}; -GLOBAL.config.erizoController = GLOBAL.config.erizoController || {}; -GLOBAL.config.erizoController.iceServers = - GLOBAL.config.erizoController.iceServers || [{'url': 'stun:stun.l.google.com:19302'}]; -GLOBAL.config.erizoController.defaultVideoBW = GLOBAL.config.erizoController.defaultVideoBW || 300; -GLOBAL.config.erizoController.maxVideoBW = GLOBAL.config.erizoController.maxVideoBW || 300; -GLOBAL.config.erizoController.publicIP = GLOBAL.config.erizoController.publicIP || ''; -GLOBAL.config.erizoController.hostname = GLOBAL.config.erizoController.hostname|| ''; -GLOBAL.config.erizoController.port = GLOBAL.config.erizoController.port || 8080; -GLOBAL.config.erizoController.ssl = GLOBAL.config.erizoController.ssl || false; +global.config = config || {}; +global.config.erizoController = global.config.erizoController || {}; +global.config.erizoController.iceServers = + global.config.erizoController.iceServers || [{'url': 'stun:stun.l.google.com:19302'}]; +global.config.erizoController.defaultVideoBW = global.config.erizoController.defaultVideoBW || 300; +global.config.erizoController.maxVideoBW = global.config.erizoController.maxVideoBW || 300; +global.config.erizoController.publicIP = global.config.erizoController.publicIP || ''; +global.config.erizoController.hostname = global.config.erizoController.hostname|| ''; +global.config.erizoController.port = global.config.erizoController.port || 8080; +global.config.erizoController.ssl = global.config.erizoController.ssl || false; // jshint ignore:start -GLOBAL.config.erizoController.ssl_key = - GLOBAL.config.erizoController.ssl_key || '../../cert/key.pem'; -GLOBAL.config.erizoController.ssl_cert = - GLOBAL.config.erizoController.ssl_cert || '../../cert/cert.pem'; -GLOBAL.config.erizoController.sslCaCerts = - GLOBAL.config.erizoController.sslCaCerts || undefined; -GLOBAL.config.erizoController.listen_port = GLOBAL.config.erizoController.listen_port || 8080; -GLOBAL.config.erizoController.listen_ssl = GLOBAL.config.erizoController.listen_ssl || false; -GLOBAL.config.erizoController.turnServer = GLOBAL.config.erizoController.turnServer || undefined; -GLOBAL.config.erizoController.warning_n_rooms = GLOBAL.config.erizoController.warning_n_rooms || 15; -GLOBAL.config.erizoController.limit_n_rooms = GLOBAL.config.erizoController.limit_n_rooms || 20; -GLOBAL.config.erizoController.interval_time_keepAlive = - GLOBAL.config.erizoController.interval_time_keepAlive || 1000; -GLOBAL.config.erizoController.report.session_events = - GLOBAL.config.erizoController.report.session_events || false; -GLOBAL.config.erizoController.recording_path = - GLOBAL.config.erizoController.recording_path || undefined; +global.config.erizoController.ssl_key = + global.config.erizoController.ssl_key || '../../cert/key.pem'; +global.config.erizoController.ssl_cert = + global.config.erizoController.ssl_cert || '../../cert/cert.pem'; +global.config.erizoController.sslCaCerts = + global.config.erizoController.sslCaCerts || undefined; +global.config.erizoController.listen_port = global.config.erizoController.listen_port || 8080; +global.config.erizoController.listen_ssl = global.config.erizoController.listen_ssl || false; +global.config.erizoController.turnServer = global.config.erizoController.turnServer || undefined; +global.config.erizoController.warning_n_rooms = global.config.erizoController.warning_n_rooms || 15; +global.config.erizoController.limit_n_rooms = global.config.erizoController.limit_n_rooms || 20; +global.config.erizoController.interval_time_keepAlive = + global.config.erizoController.interval_time_keepAlive || 1000; +global.config.erizoController.report.session_events = + global.config.erizoController.report.session_events || false; +global.config.erizoController.recording_path = + global.config.erizoController.recording_path || undefined; // jshint ignore:end -GLOBAL.config.erizoController.roles = GLOBAL.config.erizoController.roles || +global.config.erizoController.roles = global.config.erizoController.roles || {'presenter': {'publish': true, 'subscribe': true, 'record': true}, 'viewer': {'subscribe': true}, 'viewerWithData':{'subscribe': true, @@ -67,7 +67,6 @@ var getopt = new Getopt([ var PUBLISHER_INITAL = 101, PUBLISHER_READY = 104; - var opt = getopt.parse(process.argv.slice(2)); for (var prop in opt.options) { @@ -79,23 +78,23 @@ for (var prop in opt.options) { process.exit(0); break; case 'rabbit-host': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.host = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.host = value; break; case 'rabbit-port': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.port = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.port = value; break; case 'rabbit-heartbeat': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.heartbeat = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.heartbeat = value; break; case 'logging-config-file': - GLOBAL.config.logger = GLOBAL.config.logger || {}; - GLOBAL.config.logger.configFile = value; + global.config.logger = global.config.logger || {}; + global.config.logger.configFile = value; break; default: - GLOBAL.config.erizoController[prop] = value; + global.config.erizoController[prop] = value; break; } } @@ -112,7 +111,7 @@ var log = logger.getLogger('ErizoController'); var server; -if (GLOBAL.config.erizoController.listen_ssl) { // jshint ignore:line +if (global.config.erizoController.listen_ssl) { // jshint ignore:line var https = require('https'); var fs = require('fs'); var options = { @@ -131,19 +130,19 @@ if (GLOBAL.config.erizoController.listen_ssl) { // jshint ignore:line server = http.createServer(); } -server.listen(GLOBAL.config.erizoController.listen_port); // jshint ignore:line +server.listen(global.config.erizoController.listen_port); // jshint ignore:line var io = require('socket.io').listen(server, {log:false}); io.set('transports', ['websocket']); -var nuveKey = GLOBAL.config.nuve.superserviceKey; +var nuveKey = global.config.nuve.superserviceKey; -var WARNING_N_ROOMS = GLOBAL.config.erizoController.warning_n_rooms; // jshint ignore:line -var LIMIT_N_ROOMS = GLOBAL.config.erizoController.limit_n_rooms; // jshint ignore:line +var WARNING_N_ROOMS = global.config.erizoController.warning_n_rooms; // jshint ignore:line +var LIMIT_N_ROOMS = global.config.erizoController.limit_n_rooms; // jshint ignore:line -var INTERVAL_TIME_KEEPALIVE = GLOBAL.config.erizoController.interval_time_keepAlive; // jshint ignore:line +var INTERVAL_TIME_KEEPALIVE = global.config.erizoController.interval_time_keepAlive; // jshint ignore:line -var BINDED_INTERFACE_NAME = GLOBAL.config.erizoController.networkInterface; +var BINDED_INTERFACE_NAME = global.config.erizoController.networkInterface; var myId; var rooms = {}; @@ -200,8 +199,8 @@ var addToCloudHandler = function (callback) { address; for (k in interfaces) { - if (!GLOBAL.config.erizoController.networkinterface || - GLOBAL.config.erizoController.networkinterface === k) { + if (!global.config.erizoController.networkinterface || + global.config.erizoController.networkinterface === k) { if (interfaces.hasOwnProperty(k)) { for (k2 in interfaces[k]) { if (interfaces[k].hasOwnProperty(k2)) { @@ -219,11 +218,11 @@ var addToCloudHandler = function (callback) { privateRegexp = new RegExp(addresses[0], 'g'); - if (GLOBAL.config.erizoController.publicIP === '' || - GLOBAL.config.erizoController.publicIP === undefined){ + if (global.config.erizoController.publicIP === '' || + global.config.erizoController.publicIP === undefined){ publicIP = addresses[0]; } else { - publicIP = GLOBAL.config.erizoController.publicIP; + publicIP = global.config.erizoController.publicIP; } var addECToCloudHandler = function(attempt) { @@ -233,11 +232,11 @@ var addToCloudHandler = function (callback) { } var controller = { - cloudProvider: GLOBAL.config.cloudProvider.name, + cloudProvider: global.config.cloudProvider.name, ip: publicIP, - hostname: GLOBAL.config.erizoController.hostname, - port: GLOBAL.config.erizoController.port, - ssl: GLOBAL.config.erizoController.ssl + hostname: global.config.erizoController.hostname, + port: global.config.erizoController.port, + ssl: global.config.erizoController.ssl }; amqper.callRpc('nuve', 'addNewErizoController', controller, {callback: function (msg) { @@ -402,7 +401,7 @@ var listen = function () { } user = {name: tokenDB.userName, role: tokenDB.role}; socket.user = user; - var permissions = GLOBAL.config.erizoController.roles[tokenDB.role] || []; + var permissions = global.config.erizoController.roles[tokenDB.role] || []; socket.user.permissions = {}; for (var right in permissions) { socket.user.permissions[right] = permissions[right]; @@ -414,7 +413,7 @@ var listen = function () { log.debug('message: Token approved, clientId: ' + socket.id); if (!tokenDB.p2p && - GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + global.config.erizoController.report.session_events) { // jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {room: tokenDB.room, user: socket.id, @@ -434,9 +433,9 @@ var listen = function () { id: socket.room.id, p2p: socket.room.p2p, defaultVideoBW: - GLOBAL.config.erizoController.defaultVideoBW, - maxVideoBW: GLOBAL.config.erizoController.maxVideoBW, - iceServers: GLOBAL.config.erizoController.iceServers + global.config.erizoController.defaultVideoBW, + maxVideoBW: global.config.erizoController.maxVideoBW, + iceServers: global.config.erizoController.iceServers }); } else { @@ -517,7 +516,7 @@ var listen = function () { // Gets 'publish' messages on the socket in order to add new stream to the room. // Returns callback(id, error) - socket.on('publish', function (options, sdp, callback) { + socket.on('publish', function (options, sdp, callback) { var id, st; if (socket.user === undefined || !socket.user.permissions[Permission.PUBLISH]) { callback(null, 'Unauthorized'); @@ -538,8 +537,8 @@ var listen = function () { var url = sdp; if (options.state === 'recording') { var recordingId = sdp; - if (GLOBAL.config.erizoController.recording_path) { // jshint ignore:line - url = GLOBAL.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line + if (global.config.erizoController.recording_path) { // jshint ignore:line + url = global.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line } else { url = '/tmp/' + recordingId + '.mkv'; } @@ -583,7 +582,7 @@ var listen = function () { 'clientId: ' + socket.id + ', ' + 'streamId: ' + id); - if (GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + if (global.config.erizoController.report.session_events) { // jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -606,7 +605,7 @@ var listen = function () { /* if (!socket.room.p2p) { socket.room.controller.removePublisher(id); - if (GLOBAL.config.erizoController.report.session_events) { + if (global.config.erizoController.report.session_events) { var timeStamp = new Date(); amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -718,7 +717,7 @@ var listen = function () { 'streamId: ' + options.streamId); callback(true); - if (GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + if (global.config.erizoController.report.session_events) { // jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -776,8 +775,8 @@ var listen = function () { var recordingId = Math.random() * 1000000000000000000; var url; - if (GLOBAL.config.erizoController.recording_path) { // jshint ignore:line - url = GLOBAL.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line + if (global.config.erizoController.recording_path) { // jshint ignore:line + url = global.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line } else { url = '/tmp/' + recordingId + '.mkv'; } @@ -831,8 +830,8 @@ var listen = function () { var recordingId = options.id; var url; - if (GLOBAL.config.erizoController.recording_path) { // jshint ignore:line - url = GLOBAL.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line + if (global.config.erizoController.recording_path) { // jshint ignore:line + url = global.config.erizoController.recording_path + recordingId + '.mkv'; // jshint ignore:line } else { url = '/tmp/' + recordingId + '.mkv'; } @@ -867,7 +866,7 @@ var listen = function () { socket.state = 'sleeping'; if (!socket.room.p2p) { socket.room.controller.removePublisher(streamId); - if (GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + if (global.config.erizoController.report.session_events) { // jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -908,7 +907,7 @@ var listen = function () { if (!socket.room.p2p) { socket.room.controller.removeSubscriber(socket.id, to); - if (GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + if (global.config.erizoController.report.session_events) { // jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -962,7 +961,7 @@ var listen = function () { if (!socket.room.p2p) { socket.room.controller.removePublisher(id); - if (GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + if (global.config.erizoController.report.session_events) { // jshint ignore:line amqper.broadcast('event', {room: socket.room.id, user: socket.id, @@ -981,7 +980,7 @@ var listen = function () { if (socket.room !== undefined && !socket.room.p2p && - GLOBAL.config.erizoController.report.session_events) { // jshint ignore:line + global.config.erizoController.report.session_events) { // jshint ignore:line amqper.broadcast('event', {room: socket.room.id, user: socket.id, type: 'user_disconnection', diff --git a/erizo_controller/erizoJS/erizoJS.js b/erizo_controller/erizoJS/erizoJS.js index 2c5a947d90..bd4771918b 100644 --- a/erizo_controller/erizoJS/erizoJS.js +++ b/erizo_controller/erizoJS/erizoJS.js @@ -5,21 +5,21 @@ var addon; var config = require('./../../licode_config'); var mediaConfig = require('./../../rtp_media_config'); -GLOBAL.config = config || {}; -GLOBAL.config.erizo = GLOBAL.config.erizo || {}; -GLOBAL.config.erizo.numWorkers = GLOBAL.config.erizo.numWorkers || 24; -GLOBAL.config.erizo.numIOWorkers = GLOBAL.config.erizo.numIOWorkers || 1; -GLOBAL.config.erizo.useNicer = GLOBAL.config.erizo.useNicer || false; -GLOBAL.config.erizo.stunserver = GLOBAL.config.erizo.stunserver || ''; -GLOBAL.config.erizo.stunport = GLOBAL.config.erizo.stunport || 0; -GLOBAL.config.erizo.minport = GLOBAL.config.erizo.minport || 0; -GLOBAL.config.erizo.maxport = GLOBAL.config.erizo.maxport || 0; -GLOBAL.config.erizo.turnserver = GLOBAL.config.erizo.turnserver || ''; -GLOBAL.config.erizo.turnport = GLOBAL.config.erizo.turnport || 0; -GLOBAL.config.erizo.turnusername = GLOBAL.config.erizo.turnusername || ''; -GLOBAL.config.erizo.turnpass = GLOBAL.config.erizo.turnpass || ''; -GLOBAL.config.erizo.networkinterface = GLOBAL.config.erizo.networkinterface || ''; -GLOBAL.mediaConfig = mediaConfig || {}; +global.config = config || {}; +global.config.erizo = global.config.erizo || {}; +global.config.erizo.numWorkers = global.config.erizo.numWorkers || 24; +global.config.erizo.numIOWorkers = global.config.erizo.numIOWorkers || 1; +global.config.erizo.useNicer = global.config.erizo.useNicer || false; +global.config.erizo.stunserver = global.config.erizo.stunserver || ''; +global.config.erizo.stunport = global.config.erizo.stunport || 0; +global.config.erizo.minport = global.config.erizo.minport || 0; +global.config.erizo.maxport = global.config.erizo.maxport || 0; +global.config.erizo.turnserver = global.config.erizo.turnserver || ''; +global.config.erizo.turnport = global.config.erizo.turnport || 0; +global.config.erizo.turnusername = global.config.erizo.turnusername || ''; +global.config.erizo.turnpass = global.config.erizo.turnpass || ''; +global.config.erizo.networkinterface = global.config.erizo.networkinterface || ''; +global.mediaConfig = mediaConfig || {}; // Parse command line arguments var getopt = new Getopt([ ['r' , 'rabbit-host=ARG' , 'RabbitMQ Host'], @@ -49,27 +49,27 @@ for (var prop in opt.options) { process.exit(0); break; case 'rabbit-host': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.host = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.host = value; break; case 'rabbit-port': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.port = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.port = value; break; case 'rabbit-heartbeat': - GLOBAL.config.rabbit = GLOBAL.config.rabbit || {}; - GLOBAL.config.rabbit.heartbeat = value; + global.config.rabbit = global.config.rabbit || {}; + global.config.rabbit.heartbeat = value; break; case 'logging-config-file': - GLOBAL.config.logger = GLOBAL.config.logger || {}; - GLOBAL.config.logger.configFile = value; + global.config.logger = global.config.logger || {}; + global.config.logger.configFile = value; break; case 'debug': console.log('Loading debug version'); addon = require('./../../erizoAPI/build/Release/addonDebug'); break; default: - GLOBAL.config.erizo[prop] = value; + global.config.erizo[prop] = value; break; } } @@ -87,12 +87,12 @@ var controller = require('./erizoJSController'); // Logger var log = logger.getLogger('ErizoJS'); -var threadPool = new addon.ThreadPool(GLOBAL.config.erizo.numWorkers); +var threadPool = new addon.ThreadPool(global.config.erizo.numWorkers); threadPool.start(); -var ioThreadPool = new addon.IOThreadPool(GLOBAL.config.erizo.numIOWorkers); +var ioThreadPool = new addon.IOThreadPool(global.config.erizo.numIOWorkers); -if (GLOBAL.config.erizo.useNicer) { +if (global.config.erizo.useNicer) { log.info('Starting ioThreadPool'); ioThreadPool.start(); } diff --git a/erizo_controller/erizoJS/erizoJSController.js b/erizo_controller/erizoJS/erizoJSController.js index 439e85fedb..4c48996969 100644 --- a/erizo_controller/erizoJS/erizoJSController.js +++ b/erizo_controller/erizoJS/erizoJSController.js @@ -71,7 +71,7 @@ exports.ErizoJSController = function (threadPool, ioThreadPool) { monitorMinVideoBw(wrtc, callback, idPub, idSub, options, that); } - if (GLOBAL.config.erizoController.report.rtcp_stats) { // jshint ignore:line + if (global.config.erizoController.report.rtcp_stats) { // jshint ignore:line log.debug('message: RTCP Stat collection is active'); wrtc.getPeriodicStats(function (newStats) { var timeStamp = new Date(); @@ -86,7 +86,7 @@ exports.ErizoJSController = function (threadPool, ioThreadPool) { log.info('message: WebRtcConnection status update, ' + 'id: ' + wrtc.wrtcId + ', status: ' + newStatus + ', ' + logger.objectToLog(options.metadata)); - if (GLOBAL.config.erizoController.report.connection_events) { //jshint ignore:line + if (global.config.erizoController.report.connection_events) { //jshint ignore:line var timeStamp = new Date(); amqper.broadcast('event', {pub: idPub, subs: idSub, @@ -235,7 +235,7 @@ exports.ErizoJSController = function (threadPool, ioThreadPool) { }; var disableDefaultHandlers = function(wrtc) { - var disabledHandlers = GLOBAL.config.erizo.disabledHandlers; + var disabledHandlers = global.config.erizo.disabledHandlers; for (var index in disabledHandlers) { wrtc.disableHandler(disabledHandlers[index]); } @@ -580,20 +580,20 @@ exports.ErizoJSController = function (threadPool, ioThreadPool) { if (to && publishers[to]) { publisher = publishers[to]; - if (GLOBAL.config.erizoController.reportSubscriptions && - GLOBAL.config.erizoController.reportSubscriptions.maxSubscriptions > 0) { + if (global.config.erizoController.reportSubscriptions && + global.config.erizoController.reportSubscriptions.maxSubscriptions > 0) { - if (timeout > GLOBAL.config.erizoController.reportSubscriptions.maxTimeout) - timeout = GLOBAL.config.erizoController.reportSubscriptions.maxTimeout; - if (interval < GLOBAL.config.erizoController.reportSubscriptions.minInterval) - interval = GLOBAL.config.erizoController.reportSubscriptions.minInterval; + if (timeout > global.config.erizoController.reportSubscriptions.maxTimeout) + timeout = global.config.erizoController.reportSubscriptions.maxTimeout; + if (interval < global.config.erizoController.reportSubscriptions.minInterval) + interval = global.config.erizoController.reportSubscriptions.minInterval; if (statsSubscriptions[to]) { log.debug('message: Renewing subscription to stream: ' + to); clearTimeout(statsSubscriptions[to].timeout); clearInterval(statsSubscriptions[to].interval); } else if (Object.keys(statsSubscriptions).length < - GLOBAL.config.erizoController.reportSubscriptions.maxSubscriptions){ + global.config.erizoController.reportSubscriptions.maxSubscriptions){ statsSubscriptions[to] = {}; } diff --git a/erizo_controller/erizoJS/models/Publisher.js b/erizo_controller/erizoJS/models/Publisher.js index fd973ab9c7..eb50a21402 100644 --- a/erizo_controller/erizoJS/models/Publisher.js +++ b/erizo_controller/erizoJS/models/Publisher.js @@ -8,18 +8,18 @@ var log = logger.getLogger('Publisher'); function createWrtc(id, threadPool, ioThreadPool) { var wrtc = new addon.WebRtcConnection(threadPool, ioThreadPool, id, - GLOBAL.config.erizo.stunserver, - GLOBAL.config.erizo.stunport, - GLOBAL.config.erizo.minport, - GLOBAL.config.erizo.maxport, + global.config.erizo.stunserver, + global.config.erizo.stunport, + global.config.erizo.minport, + global.config.erizo.maxport, false, - JSON.stringify(GLOBAL.mediaConfig), - GLOBAL.config.erizo.useNicer, - GLOBAL.config.erizo.turnserver, - GLOBAL.config.erizo.turnport, - GLOBAL.config.erizo.turnusername, - GLOBAL.config.erizo.turnpass, - GLOBAL.config.erizo.networkinterface); + JSON.stringify(global.mediaConfig), + global.config.erizo.useNicer, + global.config.erizo.turnserver, + global.config.erizo.turnport, + global.config.erizo.turnusername, + global.config.erizo.turnpass, + global.config.erizo.networkinterface); return wrtc; } diff --git a/erizo_controller/test/erizoAgent/erizoAgent.js b/erizo_controller/test/erizoAgent/erizoAgent.js index c7de1ae95e..90fc3e26b5 100644 --- a/erizo_controller/test/erizoAgent/erizoAgent.js +++ b/erizo_controller/test/erizoAgent/erizoAgent.js @@ -37,17 +37,17 @@ describe('Erizo Agent', function() { mocks.stop(licodeConfigMock); mocks.deleteRequireCache(); mocks.reset(); - GLOBAL.config = {}; + global.config = {}; }); it('should create default globals', function() { erizoAgent = require('../../erizoAgent/erizoAgent'); - expect(GLOBAL.config.erizoAgent.maxProcesses).to.equal(1); - expect(GLOBAL.config.erizoAgent.prerunProcesses).to.equal(1); - expect(GLOBAL.config.erizoAgent.publicIP).to.equal(''); - expect(GLOBAL.config.erizoAgent.instanceLogDir).to.equal('.'); - expect(GLOBAL.config.erizoAgent.useIndividualLogFiles).to.equal(false); + expect(global.config.erizoAgent.maxProcesses).to.equal(1); + expect(global.config.erizoAgent.prerunProcesses).to.equal(1); + expect(global.config.erizoAgent.publicIP).to.equal(''); + expect(global.config.erizoAgent.instanceLogDir).to.equal('.'); + expect(global.config.erizoAgent.useIndividualLogFiles).to.equal(false); }); describe('Launch Erizo', function() { diff --git a/erizo_controller/test/erizoController/ecCloudHandler.js b/erizo_controller/test/erizoController/ecCloudHandler.js index 9e20a9db0e..624db57d82 100644 --- a/erizo_controller/test/erizoController/ecCloudHandler.js +++ b/erizo_controller/test/erizoController/ecCloudHandler.js @@ -11,8 +11,8 @@ describe('Erizo Controller / ec Cloud Handler', function() { ecCloudHandler; beforeEach(function() { - GLOBAL.config = {logger: {configFile: true}}; - GLOBAL.config.erizoController = {cloudHandlerPolicy: 'default_policy'}; + global.config = {logger: {configFile: true}}; + global.config.erizoController = {cloudHandlerPolicy: 'default_policy'}; licodeConfigMock = mocks.start(mocks.licodeConfig); amqperMock = mocks.start(mocks.amqper); spec = { @@ -26,7 +26,7 @@ describe('Erizo Controller / ec Cloud Handler', function() { mocks.stop(licodeConfigMock); mocks.deleteRequireCache(); mocks.reset(); - GLOBAL.config = {logger: {configFile: true}}; + global.config = {logger: {configFile: true}}; }); it('should have a known API', function() { diff --git a/erizo_controller/test/erizoController/erizoController.js b/erizo_controller/test/erizoController/erizoController.js index 8bf18265de..7aa698e489 100644 --- a/erizo_controller/test/erizoController/erizoController.js +++ b/erizo_controller/test/erizoController/erizoController.js @@ -19,9 +19,9 @@ describe('Erizo Controller / Erizo Controller', function() { arbitraryErizoControllerId = 'ErizoControllerId'; beforeEach(function() { - GLOBAL.config = {logger: {configFile: true}}; - GLOBAL.config.erizoController = {}; - GLOBAL.config.erizoController.report = { + global.config = {logger: {configFile: true}}; + global.config.erizoController = {}; + global.config.erizoController.report = { 'session_events': true }; signatureMock = mocks.signature; @@ -46,7 +46,7 @@ describe('Erizo Controller / Erizo Controller', function() { mocks.stop(licodeConfigMock); mocks.deleteRequireCache(); mocks.reset(); - GLOBAL.config = {}; + global.config = {}; }); it('should have a known API', function() { diff --git a/erizo_controller/test/erizoController/roomController.js b/erizo_controller/test/erizoController/roomController.js index a782cb4284..ee5c7c9b95 100644 --- a/erizo_controller/test/erizoController/roomController.js +++ b/erizo_controller/test/erizoController/roomController.js @@ -13,7 +13,7 @@ describe('Erizo Controller / Room Controller', function() { controller; beforeEach(function() { - GLOBAL.config = {logger: {configFile: true}}; + global.config = {logger: {configFile: true}}; licodeConfigMock = mocks.start(mocks.licodeConfig); amqperMock = mocks.start(mocks.amqper); ecchInstanceMock = mocks.ecchInstance; @@ -31,7 +31,7 @@ describe('Erizo Controller / Room Controller', function() { mocks.stop(licodeConfigMock); mocks.deleteRequireCache(); mocks.reset(); - GLOBAL.config = {logger: {configFile: true}}; + global.config = {logger: {configFile: true}}; }); it('should have a known API', function() { diff --git a/erizo_controller/test/erizoJS/erizoJSController.js b/erizo_controller/test/erizoJS/erizoJSController.js index 989e2bc81f..f302777699 100644 --- a/erizo_controller/test/erizoJS/erizoJSController.js +++ b/erizo_controller/test/erizoJS/erizoJSController.js @@ -21,7 +21,7 @@ describe('Erizo JS Controller', function() { beforeEach(function() { - GLOBAL.config = {logger: {configFile: true}}; + global.config = {logger: {configFile: true}}; licodeConfigMock = mocks.start(mocks.licodeConfig); amqperMock = mocks.start(mocks.amqper); erizoApiMock = mocks.start(mocks.erizoAPI); @@ -34,7 +34,7 @@ describe('Erizo JS Controller', function() { mocks.stop(licodeConfigMock); mocks.deleteRequireCache(); mocks.reset(); - GLOBAL.config = {}; + global.config = {}; }); it('should provide the known API', function() { @@ -146,8 +146,8 @@ describe('Erizo JS Controller', function() { beforeEach(function() { callback = sinon.stub(); - GLOBAL.config.erizo = {}; - GLOBAL.config.erizoController = {report: { + global.config.erizo = {}; + global.config.erizoController = {report: { 'connection_events': true, 'rtcp_stats': true}}; }); diff --git a/spine/nativeClient.js b/spine/nativeClient.js index cf776db968..28fc765bf4 100644 --- a/spine/nativeClient.js +++ b/spine/nativeClient.js @@ -6,14 +6,14 @@ const logger = require('./logger').logger; const log = logger.getLogger('NativeClient'); -GLOBAL.config = licodeConfig || {}; -GLOBAL.mediaConfig = mediaConfig || {}; +global.config = licodeConfig || {}; +global.mediaConfig = mediaConfig || {}; const threadPool = new addon.ThreadPool(10); threadPool.start(); const ioThreadPool = new addon.IOThreadPool(1); -if (GLOBAL.config.erizo.useNicer) { +if (global.config.erizo.useNicer) { ioThreadPool.start(); } @@ -105,18 +105,18 @@ exports.ErizoNativeConnection = (config) => { wrtc = new addon.WebRtcConnection(threadPool, ioThreadPool, `spine_${configuration.sessionId}`, - GLOBAL.config.erizo.stunserver, - GLOBAL.config.erizo.stunport, - GLOBAL.config.erizo.minport, - GLOBAL.config.erizo.maxport, + global.config.erizo.stunserver, + global.config.erizo.stunport, + global.config.erizo.minport, + global.config.erizo.maxport, false, - JSON.stringify(GLOBAL.mediaConfig), - GLOBAL.config.erizo.useNicer, - GLOBAL.config.erizo.turnserver, - GLOBAL.config.erizo.turnport, - GLOBAL.config.erizo.turnusername, - GLOBAL.config.erizo.turnpass, - GLOBAL.config.erizo.networkinterface); + JSON.stringify(global.mediaConfig), + global.config.erizo.useNicer, + global.config.erizo.turnserver, + global.config.erizo.turnport, + global.config.erizo.turnusername, + global.config.erizo.turnpass, + global.config.erizo.networkinterface); that.createOffer = () => { };