ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: # IGNITE-1121 Create agent-server in bin/www , not in agent-manager.js.
Date Mon, 20 Jul 2015 11:35:12 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1121 91f1fdcc1 -> 8fd577d3f


# IGNITE-1121 Create agent-server in bin/www , not in agent-manager.js.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8fd577d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8fd577d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8fd577d3

Branch: refs/heads/ignite-1121
Commit: 8fd577d3f589620f9f5a83dc53e6f098ed3bfaab
Parents: 91f1fdc
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Mon Jul 20 14:35:01 2015 +0300
Committer: sevdokimov <sergey.evdokimov@jetbrains.com>
Committed: Mon Jul 20 14:35:01 2015 +0300

----------------------------------------------------------------------
 .../nodejs/agents/agent-manager.js              | 37 ++++++++------------
 modules/web-control-center/nodejs/bin/www       | 15 ++++++--
 .../web-control-center/nodejs/routes/agent.js   |  2 +-
 3 files changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8fd577d3/modules/web-control-center/nodejs/agents/agent-manager.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/agents/agent-manager.js b/modules/web-control-center/nodejs/agents/agent-manager.js
index 2c16ac9..39d81bb 100644
--- a/modules/web-control-center/nodejs/agents/agent-manager.js
+++ b/modules/web-control-center/nodejs/agents/agent-manager.js
@@ -25,28 +25,15 @@ var ignite = require('apache-ignite');
 
 var db = require('../db');
 
-var fs = require('fs');
-
 var AgentServer = require('./agent-server').AgentServer;
 
 /**
  * @constructor
- * @param {Number} port
  */
-function AgentManager(port) {
-    this._port = port;
-
+function AgentManager(srv) {
     this._clients = {};
-}
-
-AgentManager.prototype.startup = function() {
-    this._server = https.createServer({
-        key: fs.readFileSync(config.get('monitor:server:key')),
-        cert: fs.readFileSync(config.get('monitor:server:cert')),
-        passphrase: config.get('monitor:server:keyPassphrase')
-    });
 
-    this._server.listen(this._port);
+    this._server = srv;
 
     this._wss = new WebSocketServer({ server: this._server });
 
@@ -55,7 +42,7 @@ AgentManager.prototype.startup = function() {
     this._wss.on('connection', function(ws) {
         var client = new Client(ws, self);
     });
-};
+}
 
 /**
  * @param userId
@@ -280,17 +267,21 @@ function removeFromArray(arr, val) {
 
 exports.AgentManager = AgentManager;
 
+/**
+ * @type {AgentManager}
+ */
 var manager = null;
 
+exports.createManager = function(srv) {
+    if (manager)
+        throw "Agent manager already cleared!";
+
+    manager = new AgentManager(srv);
+};
+
 /**
  * @return {AgentManager}
  */
-exports.getOrCreate = function() {
-    if (!manager) {
-        manager = new AgentManager(config.get('monitor:server:port'));
-
-        manager.startup();
-    }
-
+exports.getAgentManager = function() {
     return manager;
 };

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8fd577d3/modules/web-control-center/nodejs/bin/www
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/bin/www b/modules/web-control-center/nodejs/bin/www
index c86232c..eb1e373 100644
--- a/modules/web-control-center/nodejs/bin/www
+++ b/modules/web-control-center/nodejs/bin/www
@@ -4,9 +4,12 @@
  * Module dependencies.
  */
 var http = require('http');
+var https = require('https');
 var config = require('../helpers/configuration-loader.js');
 var app = require('../app');
-var agentServer = require('../agents/agent-manager');
+var agentManager = require('../agents/agent-manager');
+
+var fs = require('fs');
 
 var debug = require('debug')('ignite-web-control-center:server');
 
@@ -31,7 +34,15 @@ server.on('listening', onListening);
 /**
  * Start agent server.
  */
-agentServer.getOrCreate();
+var agentServer = https.createServer({
+  key: fs.readFileSync(config.get('monitor:server:key')),
+  cert: fs.readFileSync(config.get('monitor:server:cert')),
+  passphrase: config.get('monitor:server:keyPassphrase')
+});
+
+agentServer.listen(config.get('monitor:server:port'));
+
+agentManager.createManager(agentServer);
 
 /**
  * Normalize a port into a number, string, or false.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8fd577d3/modules/web-control-center/nodejs/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/agent.js b/modules/web-control-center/nodejs/routes/agent.js
index b5bdd82..1d3c199 100644
--- a/modules/web-control-center/nodejs/routes/agent.js
+++ b/modules/web-control-center/nodejs/routes/agent.js
@@ -22,7 +22,7 @@ var agentManager = require('../agents/agent-manager');
 
 /* GET summary page. */
 router.get('/', function(req, res) {
-    var c = agentManager.getOrCreate().getOneClient();
+    var c = agentManager.getAgentManager().getOneClient();
 
     if (!c) {
         return res.send("Client not found");


Mime
View raw message