cloudcms-server 3.2.327 → 3.2.329

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
@@ -29,26 +29,31 @@ process.logInfo = process.log = function(text, level)
29
29
  systemLogger.log(text, level);
30
30
  };
31
31
 
32
+ var debugLog = process.debugLog = function(req, message)
33
+ {
34
+ var text = "[" + req.id + "] URL: " + req.url;
35
+ // if (req.headers)
36
+ // {
37
+ // text += ", HEADERS: " + JSON.stringify(req.headers);
38
+ // }
39
+ if (req.query)
40
+ {
41
+ text += ", QUERY: " + JSON.stringify(req.query);
42
+ }
43
+ text += ", MESSAGE: " + message;
44
+
45
+ console.log(text);
46
+ };
47
+
32
48
  var debugMiddleware = process.debugMiddleware = function(message)
33
49
  {
34
50
  return function(req, res, next)
35
51
  {
36
- var text = "[" + req.id + "] URL: " + req.url;
37
- // if (req.headers)
38
- // {
39
- // text += ", HEADERS: " + JSON.stringify(req.headers);
40
- // }
41
- if (req.query)
42
- {
43
- text += ", QUERY: " + JSON.stringify(req.query);
44
- }
45
- text += ", MESSAGE: " + message;
46
-
47
- console.log(text);
52
+ debugLog(req, message);
48
53
 
49
54
  next();
50
55
  }
51
- }
56
+ };
52
57
 
53
58
 
54
59
 
@@ -2,6 +2,8 @@ var util = require("../../util/util");
2
2
 
3
3
  var workQueueFactory = require("../../util/workqueue");
4
4
 
5
+ var debugLog = process.debugLog;
6
+
5
7
  /**
6
8
  * Retrieves virtual driver configuration for hosts from Cloud CMS.
7
9
  *
@@ -162,13 +164,19 @@ exports = module.exports = function()
162
164
 
163
165
  var VCSENTINEL_CACHE_KEY = "vcSentinelFailed-" + host;
164
166
 
167
+ console.log("[acquireGitanaJson] host: " + host + " - t1");
168
+
165
169
  // so that only N number of virtual configs are loaded at a time
166
170
  enqueueLoadVirtualConfig(function(host, rootStore, logMethod, callback) {
167
171
 
168
172
  return function()
169
173
  {
174
+ console.log("[acquireGitanaJson] host: " + host + " - t2");
175
+
170
176
  rootStore.existsFile("gitana.json", function(exists) {
171
177
 
178
+ console.log("[acquireGitanaJson] host: " + host + " - t3, exists:" + exists);
179
+
172
180
  var loadFromRemote = function(finishedLoading) {
173
181
 
174
182
  // check cache to see if we already tried to load this in the past few minutes and were sorely disappointed
@@ -261,16 +269,23 @@ exports = module.exports = function()
261
269
 
262
270
  if (exists)
263
271
  {
272
+ console.log("[acquireGitanaJson] host: " + host + " - t4");
273
+
264
274
  // read gitana json and send back
265
275
  rootStore.readFile("gitana.json", function(err, data) {
266
276
 
267
277
  if (err)
268
278
  {
279
+ console.log("[acquireGitanaJson] host: " + host + " - t5");
269
280
  return callback(err);
270
281
  }
271
282
 
283
+ console.log("[acquireGitanaJson] host: " + host + " - t6: " + data);
284
+
272
285
  if (!data)
273
286
  {
287
+ console.log("[acquireGitanaJson] host: " + host + " - t7");
288
+
274
289
  return callback({
275
290
  "message": "The gitana.json data read from disk was null or empty"
276
291
  })
@@ -281,12 +296,16 @@ exports = module.exports = function()
281
296
 
282
297
  if (err)
283
298
  {
299
+ console.log("[acquireGitanaJson] host: " + host + " - t8");
284
300
  return callback(err);
285
301
  }
286
302
 
303
+ console.log("[acquireGitanaJson] host: " + host + " - t9");
304
+
287
305
  // if we failed to read stats or file size 0, then delete and call back with error
288
306
  if (err || stats.size === 0)
289
307
  {
308
+ console.log("[acquireGitanaJson] host: " + host + " - t10");
290
309
  return rootStore.deleteFile("gitana.json", function() {
291
310
  callback({
292
311
  "message": "There was a problem writing the driver configuration file. Please reload."
@@ -294,6 +313,8 @@ exports = module.exports = function()
294
313
  });
295
314
  }
296
315
 
316
+ console.log("[acquireGitanaJson] host: " + host + " - t11");
317
+
297
318
  // remove vcSentinel if it exists
298
319
  process.cache.remove(VCSENTINEL_CACHE_KEY);
299
320
 
@@ -316,6 +337,8 @@ exports = module.exports = function()
316
337
  }
317
338
  }
318
339
 
340
+ console.log("[acquireGitanaJson] host: " + host + " - t20: " + JSON.stringify(gitanaJson, null, 2));
341
+
319
342
  // otherwise, fine!
320
343
  callback(null, gitanaJson);
321
344
  });
@@ -355,8 +378,11 @@ exports = module.exports = function()
355
378
 
356
379
  var completionFunction = function (err, gitanaConfig, doesNotExist)
357
380
  {
381
+ debugLog(req, "g20");
358
382
  if (doesNotExist)
359
383
  {
384
+ debugLog(req, "g21");
385
+
360
386
  // console.log("BLOCK, method: " + req.method + ", url: " + req.url);
361
387
  // if (req.headers)
362
388
  // {
@@ -373,6 +399,8 @@ exports = module.exports = function()
373
399
  return res.end(JSON.stringify({"error": true, "message": "Bad Request."}));
374
400
  }
375
401
 
402
+ debugLog(req, "g22");
403
+
376
404
  if (err)
377
405
  {
378
406
  if (err.message)
@@ -380,11 +408,15 @@ exports = module.exports = function()
380
408
  req.log(err.message);
381
409
  }
382
410
 
411
+ debugLog(req, "g23: " + err);
412
+
383
413
  return next();
384
414
  }
385
415
 
386
416
  if (gitanaConfig)
387
417
  {
418
+ debugLog(req, "g24: " + JSON.stringify(gitanaConfig, null, 2));
419
+
388
420
  // store config
389
421
  req.gitanaConfig = gitanaConfig;
390
422
 
@@ -392,11 +424,18 @@ exports = module.exports = function()
392
424
  req.gitanaLocal = false;
393
425
  }
394
426
 
427
+ debugLog(req, "g30");
428
+
395
429
  next();
396
430
  };
397
431
 
432
+ debugLog(req, "g1: " + req.virtualHost);
433
+
398
434
  process.driverConfigCache.read(req.virtualHost, function(err, cachedValue)
399
435
  {
436
+ debugLog(req, "g2: " + err);
437
+ debugLog(req, "g3: " + cachedValue);
438
+
400
439
  if (process.env.NULL_DRIVER_CACHE === "true") {
401
440
  cachedValue = null;
402
441
  }
@@ -405,20 +444,29 @@ exports = module.exports = function()
405
444
  {
406
445
  if (cachedValue === SENTINEL_NOT_FOUND_VALUE)
407
446
  {
447
+ debugLog(req, "g4");
448
+
408
449
  // null means there verifiably isn't anything on disk (null used as sentinel marker)
409
450
  completionFunction(null, null, true);
410
451
  }
411
452
  else
412
453
  {
454
+ debugLog(req, "g5");
455
+
413
456
  // we have something in cache
414
457
  completionFunction(null, cachedValue.config);
415
458
  }
416
459
  }
417
460
  else
418
461
  {
462
+ debugLog(req, "g6");
463
+
419
464
  // try to load from disk
420
465
  acquireGitanaJson(req.virtualHost, req.rootStore, req.log, function (err, gitanaConfig, doesNotExist)
421
466
  {
467
+ debugLog(req, "g7: " + err);
468
+ debugLog(req, "g8: " + gitanaConfig);
469
+
422
470
  if (err && !doesNotExist)
423
471
  {
424
472
  return completionFunction(err);
@@ -426,6 +474,8 @@ exports = module.exports = function()
426
474
 
427
475
  if (gitanaConfig)
428
476
  {
477
+ debugLog(req, "g9: " + JSON.stringify(gitanaConfig, null, 2));
478
+
429
479
  return process.driverConfigCache.write(req.virtualHost, {
430
480
  "config": gitanaConfig
431
481
  }, function (err) {
@@ -433,6 +483,8 @@ exports = module.exports = function()
433
483
  });
434
484
  }
435
485
 
486
+ debugLog(req, "g10: " + req.virtualHost);
487
+
436
488
  // mark with sentinel (30 minutes)
437
489
  req.log("[BLACKLIST] Adding: " + req.virtualHost);
438
490
  process.driverConfigCache.write(req.virtualHost, SENTINEL_NOT_FOUND_VALUE, BLACKLIST_TTL_SECONDS, function (err) {
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.327",
9
+ "version": "3.2.329",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"