cloudcms-server 3.2.330 → 3.2.331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -49,7 +49,7 @@ var debugMiddleware = process.debugMiddleware = function(message)
49
49
  {
50
50
  return function(req, res, next)
51
51
  {
52
- debugLog(req, message);
52
+ //debugLog(req, message);
53
53
 
54
54
  next();
55
55
  }
@@ -167,9 +167,9 @@ exports = module.exports = function()
167
167
  console.log("[acquireGitanaJson] host: " + host + " - t1");
168
168
 
169
169
  // so that only N number of virtual configs are loaded at a time
170
- enqueueLoadVirtualConfig(function(host, rootStore, logMethod, callback) {
170
+ var workFn = function(host, rootStore, logMethod) {
171
171
 
172
- return function()
172
+ return function(done)
173
173
  {
174
174
  console.log("[acquireGitanaJson] host: " + host + " - t2");
175
175
 
@@ -277,7 +277,7 @@ exports = module.exports = function()
277
277
  if (err)
278
278
  {
279
279
  console.log("[acquireGitanaJson] host: " + host + " - t5");
280
- return callback(err);
280
+ return done(err);
281
281
  }
282
282
 
283
283
  console.log("[acquireGitanaJson] host: " + host + " - t6: " + data);
@@ -286,7 +286,7 @@ exports = module.exports = function()
286
286
  {
287
287
  console.log("[acquireGitanaJson] host: " + host + " - t7");
288
288
 
289
- return callback({
289
+ return done({
290
290
  "message": "The gitana.json data read from disk was null or empty"
291
291
  })
292
292
  }
@@ -297,7 +297,7 @@ exports = module.exports = function()
297
297
  if (err)
298
298
  {
299
299
  console.log("[acquireGitanaJson] host: " + host + " - t8");
300
- return callback(err);
300
+ return done(err);
301
301
  }
302
302
 
303
303
  console.log("[acquireGitanaJson] host: " + host + " - t9");
@@ -307,7 +307,7 @@ exports = module.exports = function()
307
307
  {
308
308
  console.log("[acquireGitanaJson] host: " + host + " - t10");
309
309
  return rootStore.deleteFile("gitana.json", function() {
310
- callback({
310
+ done({
311
311
  "message": "There was a problem writing the driver configuration file. Please reload."
312
312
  });
313
313
  });
@@ -340,20 +340,24 @@ exports = module.exports = function()
340
340
  console.log("[acquireGitanaJson] host: " + host + " - t20: " + JSON.stringify(gitanaJson, null, 2));
341
341
 
342
342
  // otherwise, fine!
343
- callback(null, gitanaJson);
343
+ done(null, gitanaJson);
344
344
  });
345
345
  });
346
346
  }
347
347
  else
348
348
  {
349
349
  loadFromRemote(function(err, gitanaJson, doesNotExist) {
350
- callback(err, gitanaJson, doesNotExist);
350
+ done(err, gitanaJson, doesNotExist);
351
351
  });
352
352
  }
353
353
  });
354
354
  }
355
355
 
356
- }(host, rootStore, logMethod, callback));
356
+ }(host, rootStore, logMethod);
357
+
358
+ enqueueLoadVirtualConfig(workFn, function(err) {
359
+ callback(err);
360
+ });
357
361
  };
358
362
 
359
363
  r.interceptor = function()
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "3.2.330",
9
+ "version": "3.2.331",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
package/server/index.js CHANGED
@@ -1261,7 +1261,7 @@ var createHttpServer = function(app, done)
1261
1261
  // socket
1262
1262
  httpServer.on("connection", function (socket) {
1263
1263
 
1264
- console.log("[SOCKET CONNECTION] " + socket);
1264
+ //console.log("[SOCKET CONNECTION] " + socket);
1265
1265
 
1266
1266
  socket.setNoDelay(true);
1267
1267
 
package/util/workqueue.js CHANGED
@@ -6,7 +6,7 @@ module.exports = function(maxSize)
6
6
 
7
7
  var blockExecution = false;
8
8
 
9
- var pendingWorkFns = [];
9
+ var pendingWorkQueue = [];
10
10
  var activeCount = 0;
11
11
 
12
12
  var processWork = function () {
@@ -24,7 +24,7 @@ module.exports = function(maxSize)
24
24
  do
25
25
  {
26
26
  // if nothing to work on, bail
27
- if (pendingWorkFns.length === 0)
27
+ if (pendingWorkQueue.length === 0)
28
28
  {
29
29
  process = false;
30
30
  }
@@ -43,21 +43,34 @@ module.exports = function(maxSize)
43
43
  console.log("Active work items: " + activeCount);
44
44
 
45
45
  // define execution function and splice/bind to 0th element from pending list
46
- var executionFn = function(workFn) {
46
+ var executionFn = function(work) {
47
47
  return function() {
48
- workFn(function () {
48
+ var workFn = work.workFn;
49
+ var callbackFn = work.callbackFn;
50
+
51
+ console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] start work");
52
+
53
+ workFn(function(err) {
49
54
 
50
55
  // decrement active count
51
56
  activeCount--;
52
57
 
53
- console.log("Active work items: " + activeCount);
58
+ console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] finish work");
59
+
60
+ // fire optional callback
61
+ if (callbackFn) {
62
+ console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] fire work callback");
63
+ window.setTimeout(function() {
64
+ callbackFn(err);
65
+ });
66
+ }
54
67
 
55
68
  // process more work on timeout
56
69
  window.setTimeout(processWork);
57
70
  });
58
71
 
59
72
  };
60
- }(pendingWorkFns.splice(0, 1)[0]);
73
+ }(pendingWorkQueue.splice(0, 1)[0]);
61
74
 
62
75
  // execute on timeout
63
76
  window.setTimeout(executionFn);
@@ -68,10 +81,19 @@ module.exports = function(maxSize)
68
81
  blockExecution = false;
69
82
  };
70
83
 
71
- return function(workFn) {
72
- pendingWorkFns.push(workFn);
84
+ return function(workFn, callbackFn) {
85
+
86
+ var pendingWork = {
87
+ "workFn": workFn
88
+ };
89
+
90
+ if (callbackFn) {
91
+ pendingWork.callbackFn = callbackFn;
92
+ }
93
+
94
+ pendingWorkQueue.push(pendingWork);
73
95
 
74
- console.log("PENDING WORK FUNCTIONS: " + pendingWorkFns.length);
96
+ console.log("PENDING WORK FUNCTIONS: " + pendingWorkQueue.length);
75
97
 
76
98
  // execute on timeout
77
99
  window.setTimeout(processWork);