cloudcms-server 3.2.334 → 3.2.336

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,31 +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
-
48
- var debugMiddleware = process.debugMiddleware = function(message)
49
- {
50
- return function(req, res, next)
51
- {
52
- //debugLog(req, message);
53
-
54
- next();
55
- }
56
- };
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
+ //
48
+ // var debugMiddleware = process.debugMiddleware = function(message)
49
+ // {
50
+ // return function(req, res, next)
51
+ // {
52
+ // debugLog(req, message);
53
+ //
54
+ // next();
55
+ // }
56
+ // };
57
57
 
58
58
 
59
59
 
@@ -333,82 +333,43 @@ exports = module.exports = function()
333
333
 
334
334
  r.common1 = function(app)
335
335
  {
336
- // DEBUG
337
- app.use(debugMiddleware("DEBUG x1"));
338
-
339
336
  // app config interceptor
340
337
  applyApplicationConfiguration(app);
341
338
 
342
- // DEBUG
343
- app.use(debugMiddleware("DEBUG x2"));
344
-
345
339
  // sets locale onto the request
346
340
  app.use(locale.localeInterceptor());
347
341
 
348
- // DEBUG
349
- app.use(debugMiddleware("DEBUG x3"));
350
-
351
342
  // sets host onto the request
352
343
  app.use(host.hostInterceptor());
353
-
354
- // DEBUG
355
- app.use(debugMiddleware("DEBUG x4"));
356
344
  };
357
345
 
358
346
  r.common2 = function(app)
359
347
  {
360
- // DEBUG
361
- app.use(debugMiddleware("DEBUG y1"));
362
-
363
348
  // bind stores into the request
364
349
  app.use(storeService.storesInterceptor());
365
350
 
366
- // DEBUG
367
- app.use(debugMiddleware("DEBUG y2"));
368
-
369
351
  // puts req.descriptor into the request and req.virtualFiles = true
370
352
  app.use(virtualFiles.interceptor());
371
353
 
372
- // DEBUG
373
- app.use(debugMiddleware("DEBUG y3"));
374
-
375
354
  // puts req.runtime into the request
376
355
  app.use(runtime.interceptor());
377
356
 
378
- // DEBUG
379
- app.use(debugMiddleware("DEBUG y4"));
380
-
381
357
  // if virtual hosting is enabled, loads "gitana.json" from cloud cms and places it into rootStore
382
358
  // for convenience, also populates req.gitanaConfig
383
359
  app.use(virtualConfig.interceptor());
384
360
 
385
- // DEBUG
386
- app.use(debugMiddleware("DEBUG y5"));
387
-
388
361
  // general method for finding "gitana.json" in root store and populating req.gitanaConfig
389
362
  app.use(driverConfig.interceptor());
390
-
391
- // DEBUG
392
- app.use(debugMiddleware("DEBUG y6"));
393
363
  };
394
364
 
395
365
  r.common3 = function(app)
396
366
  {
397
- // DEBUG
398
- app.use(debugMiddleware("DEBUG z1"));
399
-
400
367
  // binds "req.gitana" into the request for the loaded "req.gitanaConfig"
401
368
  app.use(driver.driverInterceptor());
402
-
403
- // DEBUG
404
- app.use(debugMiddleware("DEBUG z2"));
405
369
  };
406
370
 
407
371
  r.common4 = function(app, includeCloudCMS)
408
372
  {
409
- // DEBUG
410
- app.use(debugMiddleware("DEBUG v1"));
411
-
412
373
  var configuration = app.configuration;
413
374
 
414
375
  if (includeCloudCMS)
@@ -441,9 +402,6 @@ exports = module.exports = function()
441
402
 
442
403
  // graphql
443
404
  app.use(graphql.interceptor());
444
-
445
- // DEBUG
446
- app.use(debugMiddleware("DEBUG v2"));
447
405
  };
448
406
 
449
407
  r.perf1 = function(app)
@@ -2,7 +2,7 @@ var util = require("../../util/util");
2
2
 
3
3
  var workQueueFactory = require("../../util/workqueue");
4
4
 
5
- var debugLog = process.debugLog;
5
+ //var debugLog = process.debugLog;
6
6
 
7
7
  /**
8
8
  * Retrieves virtual driver configuration for hosts from Cloud CMS.
@@ -164,19 +164,13 @@ exports = module.exports = function()
164
164
 
165
165
  var VCSENTINEL_CACHE_KEY = "vcSentinelFailed-" + host;
166
166
 
167
- console.log("[acquireGitanaJson] host: " + host + " - t1");
168
-
169
167
  // so that only N number of virtual configs are loaded at a time
170
168
  var workFn = function(host, rootStore, logMethod) {
171
169
 
172
170
  return function(done)
173
171
  {
174
- console.log("[acquireGitanaJson] host: " + host + " - t2");
175
-
176
172
  rootStore.existsFile("gitana.json", function(exists) {
177
173
 
178
- console.log("[acquireGitanaJson] host: " + host + " - t3, exists:" + exists);
179
-
180
174
  var loadFromRemote = function(finishedLoading) {
181
175
 
182
176
  // check cache to see if we already tried to load this in the past few minutes and were sorely disappointed
@@ -269,23 +263,16 @@ exports = module.exports = function()
269
263
 
270
264
  if (exists)
271
265
  {
272
- console.log("[acquireGitanaJson] host: " + host + " - t4");
273
-
274
266
  // read gitana json and send back
275
267
  rootStore.readFile("gitana.json", function(err, data) {
276
268
 
277
269
  if (err)
278
270
  {
279
- console.log("[acquireGitanaJson] host: " + host + " - t5");
280
271
  return done(err);
281
272
  }
282
273
 
283
- console.log("[acquireGitanaJson] host: " + host + " - t6: " + data);
284
-
285
274
  if (!data)
286
275
  {
287
- console.log("[acquireGitanaJson] host: " + host + " - t7");
288
-
289
276
  return done({
290
277
  "message": "The gitana.json data read from disk was null or empty"
291
278
  })
@@ -296,16 +283,12 @@ exports = module.exports = function()
296
283
 
297
284
  if (err)
298
285
  {
299
- console.log("[acquireGitanaJson] host: " + host + " - t8");
300
286
  return done(err);
301
287
  }
302
288
 
303
- console.log("[acquireGitanaJson] host: " + host + " - t9");
304
-
305
289
  // if we failed to read stats or file size 0, then delete and call back with error
306
290
  if (err || stats.size === 0)
307
291
  {
308
- console.log("[acquireGitanaJson] host: " + host + " - t10");
309
292
  return rootStore.deleteFile("gitana.json", function() {
310
293
  done({
311
294
  "message": "There was a problem writing the driver configuration file. Please reload."
@@ -313,8 +296,6 @@ exports = module.exports = function()
313
296
  });
314
297
  }
315
298
 
316
- console.log("[acquireGitanaJson] host: " + host + " - t11");
317
-
318
299
  // remove vcSentinel if it exists
319
300
  process.cache.remove(VCSENTINEL_CACHE_KEY);
320
301
 
@@ -337,8 +318,6 @@ exports = module.exports = function()
337
318
  }
338
319
  }
339
320
 
340
- console.log("[acquireGitanaJson] host: " + host + " - t20: " + JSON.stringify(gitanaJson, null, 2));
341
-
342
321
  // otherwise, fine!
343
322
  done(null, gitanaJson);
344
323
  });
@@ -382,11 +361,8 @@ exports = module.exports = function()
382
361
 
383
362
  var completionFunction = function (err, gitanaConfig, doesNotExist)
384
363
  {
385
- debugLog(req, "g20");
386
364
  if (doesNotExist)
387
365
  {
388
- debugLog(req, "g21");
389
-
390
366
  // console.log("BLOCK, method: " + req.method + ", url: " + req.url);
391
367
  // if (req.headers)
392
368
  // {
@@ -403,8 +379,6 @@ exports = module.exports = function()
403
379
  return res.end(JSON.stringify({"error": true, "message": "Bad Request."}));
404
380
  }
405
381
 
406
- debugLog(req, "g22");
407
-
408
382
  if (err)
409
383
  {
410
384
  if (err.message)
@@ -412,15 +386,11 @@ exports = module.exports = function()
412
386
  req.log(err.message);
413
387
  }
414
388
 
415
- debugLog(req, "g23: " + err);
416
-
417
389
  return next();
418
390
  }
419
391
 
420
392
  if (gitanaConfig)
421
393
  {
422
- debugLog(req, "g24: " + JSON.stringify(gitanaConfig, null, 2));
423
-
424
394
  // store config
425
395
  req.gitanaConfig = gitanaConfig;
426
396
 
@@ -428,18 +398,11 @@ exports = module.exports = function()
428
398
  req.gitanaLocal = false;
429
399
  }
430
400
 
431
- debugLog(req, "g30");
432
-
433
401
  next();
434
402
  };
435
403
 
436
- debugLog(req, "g1: " + req.virtualHost);
437
-
438
404
  process.driverConfigCache.read(req.virtualHost, function(err, cachedValue)
439
405
  {
440
- debugLog(req, "g2: " + err);
441
- debugLog(req, "g3: " + cachedValue);
442
-
443
406
  if (process.env.NULL_DRIVER_CACHE === "true") {
444
407
  cachedValue = null;
445
408
  }
@@ -448,29 +411,20 @@ exports = module.exports = function()
448
411
  {
449
412
  if (cachedValue === SENTINEL_NOT_FOUND_VALUE)
450
413
  {
451
- debugLog(req, "g4");
452
-
453
414
  // null means there verifiably isn't anything on disk (null used as sentinel marker)
454
415
  completionFunction(null, null, true);
455
416
  }
456
417
  else
457
418
  {
458
- debugLog(req, "g5");
459
-
460
419
  // we have something in cache
461
420
  completionFunction(null, cachedValue.config);
462
421
  }
463
422
  }
464
423
  else
465
424
  {
466
- debugLog(req, "g6");
467
-
468
425
  // try to load from disk
469
426
  acquireGitanaJson(req.virtualHost, req.rootStore, req.log, function (err, gitanaConfig, doesNotExist)
470
427
  {
471
- debugLog(req, "g7: " + err);
472
- debugLog(req, "g8: " + gitanaConfig);
473
-
474
428
  if (err && !doesNotExist)
475
429
  {
476
430
  return completionFunction(err);
@@ -478,8 +432,6 @@ exports = module.exports = function()
478
432
 
479
433
  if (gitanaConfig)
480
434
  {
481
- debugLog(req, "g9: " + JSON.stringify(gitanaConfig, null, 2));
482
-
483
435
  return process.driverConfigCache.write(req.virtualHost, {
484
436
  "config": gitanaConfig
485
437
  }, function (err) {
@@ -487,8 +439,6 @@ exports = module.exports = function()
487
439
  });
488
440
  }
489
441
 
490
- debugLog(req, "g10: " + req.virtualHost);
491
-
492
442
  // mark with sentinel (30 minutes)
493
443
  req.log("[BLACKLIST] Adding: " + req.virtualHost);
494
444
  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.334",
9
+ "version": "3.2.336",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
package/server/index.js CHANGED
@@ -729,7 +729,7 @@ var initSession = function(initDone)
729
729
  }
730
730
  };
731
731
 
732
- var debugMiddleware = process.debugMiddleware;
732
+ //var debugMiddleware = process.debugMiddleware;
733
733
 
734
734
  var startServer = function(config, startServerFinishedFn)
735
735
  {
@@ -899,9 +899,6 @@ var startServer = function(config, startServerFinishedFn)
899
899
  next();
900
900
  });
901
901
 
902
- // DEBUG
903
- app.use(debugMiddleware("DEBUG 1"));
904
-
905
902
  // APPLY CUSTOM INIT FUNCTIONS
906
903
  runFunctions(config.initFunctions, [app], function (err) {
907
904
 
@@ -995,9 +992,6 @@ var startServer = function(config, startServerFinishedFn)
995
992
  // common interceptors and config
996
993
  main.common1(app);
997
994
 
998
- // DEBUG
999
- app.use(debugMiddleware("DEBUG 2"));
1000
-
1001
995
  // general logging of requests
1002
996
  // gather statistics on response time
1003
997
  app.use(responseTime(function (req, res, time) {
@@ -1037,28 +1031,16 @@ var startServer = function(config, startServerFinishedFn)
1037
1031
  req.log(m, warn);
1038
1032
  }));
1039
1033
 
1040
- // DEBUG
1041
- app.use(debugMiddleware("DEBUG 2a"));
1042
-
1043
1034
  // set up CORS allowances
1044
1035
  // this lets CORS requests float through the proxy
1045
1036
  app.use(main.ensureCORS());
1046
1037
 
1047
- // DEBUG
1048
- app.use(debugMiddleware("DEBUG 2b"));
1049
-
1050
1038
  // set up default security headers
1051
1039
  app.use(main.ensureHeaders());
1052
1040
 
1053
- // DEBUG
1054
- app.use(debugMiddleware("DEBUG 2c"));
1055
-
1056
1041
  // common interceptors and config
1057
1042
  main.common2(app);
1058
1043
 
1059
- // DEBUG
1060
- app.use(debugMiddleware("DEBUG 3"));
1061
-
1062
1044
  // APPLY CUSTOM DRIVER FUNCTIONS
1063
1045
  runFunctions(config.driverFunctions, [app], function(err) {
1064
1046
 
@@ -1071,9 +1053,6 @@ var startServer = function(config, startServerFinishedFn)
1071
1053
  // cloudcms things need to run here
1072
1054
  main.common4(app, true);
1073
1055
 
1074
- // DEBUG
1075
- app.use(debugMiddleware("DEBUG 4"));
1076
-
1077
1056
  // APPLY CUSTOM FILTER FUNCTIONS
1078
1057
  runFunctions(config.filterFunctions, [app], function (err) {
1079
1058
 
@@ -1089,9 +1068,6 @@ var startServer = function(config, startServerFinishedFn)
1089
1068
  // DEVELOPMENT BASED PERFORMANCE CACHING
1090
1069
  main.perf3(app);
1091
1070
 
1092
- // DEBUG
1093
- app.use(debugMiddleware("DEBUG 5"));
1094
-
1095
1071
  // standard body parsing + a special cloud cms body parser that makes a last ditch effort for anything
1096
1072
  // that might be JSON (regardless of content type)
1097
1073
  app.use(function (req, res, next) {
@@ -1114,9 +1090,6 @@ var startServer = function(config, startServerFinishedFn)
1114
1090
  app.use(flash());
1115
1091
  }
1116
1092
 
1117
- // DEBUG
1118
- app.use(debugMiddleware("DEBUG 6"));
1119
-
1120
1093
  // this is the same as calling
1121
1094
  // app.use(passport.initialize());
1122
1095
  // except we create a new passport each time and store on request to support multitenancy
@@ -1156,9 +1129,6 @@ var startServer = function(config, startServerFinishedFn)
1156
1129
  });
1157
1130
  }
1158
1131
 
1159
- // DEBUG
1160
- app.use(debugMiddleware("DEBUG 7"));
1161
-
1162
1132
  // welcome files
1163
1133
  main.welcome(app);
1164
1134
 
@@ -1170,21 +1140,12 @@ var startServer = function(config, startServerFinishedFn)
1170
1140
  // healthcheck middleware
1171
1141
  main.healthcheck(app);
1172
1142
 
1173
- // DEBUG
1174
- app.use(debugMiddleware("DEBUG 8"));
1175
-
1176
1143
  // APPLY CUSTOM ROUTES
1177
1144
  runFunctions(config.routeFunctions, [app], function (err) {
1178
1145
 
1179
- // DEBUG
1180
- app.use(debugMiddleware("DEBUG 9"));
1181
-
1182
1146
  // configure cloudcms app server handlers
1183
1147
  main.handlers(app, true);
1184
1148
 
1185
- // DEBUG
1186
- app.use(debugMiddleware("DEBUG 10"));
1187
-
1188
1149
  // register error functions
1189
1150
  runFunctions(config.errorFunctions, [app], function (err) {
1190
1151
 
package/util/workqueue.js CHANGED
@@ -40,7 +40,7 @@ module.exports = function(maxSize)
40
40
  // increment active count
41
41
  activeCount++;
42
42
 
43
- console.log("Active work items: " + activeCount);
43
+ // console.log("Active work items: " + activeCount);
44
44
 
45
45
  // define execution function and splice/bind to 0th element from pending list
46
46
  var executionFn = function(work) {
@@ -48,18 +48,18 @@ module.exports = function(maxSize)
48
48
  var workFn = work.workFn;
49
49
  var callbackFn = work.callbackFn;
50
50
 
51
- console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] start work");
51
+ // console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] start work");
52
52
 
53
53
  workFn(function(err, obj1, obj2) {
54
54
 
55
55
  // decrement active count
56
56
  activeCount--;
57
57
 
58
- console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] finish work");
58
+ // console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] finish work");
59
59
 
60
60
  // fire optional callback
61
61
  if (callbackFn) {
62
- console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] fire work callback");
62
+ // console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] fire work callback");
63
63
  window.setTimeout(function() {
64
64
  callbackFn(err, obj1, obj2);
65
65
  });
@@ -93,8 +93,6 @@ module.exports = function(maxSize)
93
93
 
94
94
  pendingWorkQueue.push(pendingWork);
95
95
 
96
- console.log("PENDING WORK FUNCTIONS: " + pendingWorkQueue.length);
97
-
98
96
  // execute on timeout
99
97
  window.setTimeout(processWork);
100
98
  };