cloudcms-server 4.0.0-beta.10 → 4.0.0-beta.14
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/README.md +0 -5
- package/index.js +58 -32
- package/middleware/authentication/authentication.js +40 -12
- package/middleware/authentication/providers/saml.js +7 -3
- package/middleware/config/adapter.js +0 -44
- package/middleware/deployment/deployment.js +22 -24
- package/middleware/driver/driver.js +24 -1
- package/middleware/registration/registration.js +0 -5
- package/middleware/stores/engines/empty.js +0 -4
- package/middleware/stores/engines/fs-caching-adapter.js +0 -5
- package/middleware/stores/engines/fs.js +0 -9
- package/middleware/stores/engines/s3.js +0 -5
- package/middleware/stores/engines/s3fs.js +0 -5
- package/middleware/stores/multistore.js +0 -29
- package/middleware/stores/store.js +0 -9
- package/middleware/virtual-config/virtual-config.js +253 -203
- package/package.json +34 -49
- package/server/index.js +166 -111
- package/server/standalone.js +1 -6
- package/util/cloudcms.js +34 -7
- package/util/loaders.js +113 -0
- package/util/workqueue.js +100 -0
- package/duster/helpers/core/cloudcms/associations.js +0 -34
- package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
- package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
- package/duster/helpers/core/cloudcms/beta/params.js +0 -33
- package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
- package/duster/helpers/core/cloudcms/content.js +0 -34
- package/duster/helpers/core/cloudcms/expand.js +0 -38
- package/duster/helpers/core/cloudcms/form.js +0 -34
- package/duster/helpers/core/cloudcms/query.js +0 -34
- package/duster/helpers/core/cloudcms/queryOne.js +0 -34
- package/duster/helpers/core/cloudcms/relatives.js +0 -34
- package/duster/helpers/core/cloudcms/search.js +0 -34
- package/duster/helpers/core/cloudcms/searchOne.js +0 -34
- package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
- package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
- package/duster/helpers/core/dev/debug.js +0 -42
- package/duster/helpers/core/dom/block.js +0 -49
- package/duster/helpers/core/dom/include.js +0 -38
- package/duster/helpers/core/dom/layout.js +0 -49
- package/duster/helpers/core/dom/link.js +0 -81
- package/duster/helpers/core/dom/resource.js +0 -77
- package/duster/helpers/core/engine.js +0 -1580
- package/duster/helpers/core/ice/value.js +0 -65
- package/duster/helpers/core/index.js +0 -49
- package/duster/helpers/core/operators/if.js +0 -64
- package/duster/helpers/core/operators/iter.js +0 -45
- package/duster/helpers/core/operators/iterate.js +0 -129
- package/duster/helpers/sample/nyt.js +0 -114
- package/duster/index.js +0 -319
- package/duster/support.js +0 -436
- package/duster/tracker.js +0 -262
- package/middleware/authentication/providers/cas.js +0 -73
- package/middleware/authentication/providers/facebook.js +0 -120
- package/middleware/authentication/providers/github.js +0 -88
- package/middleware/authentication/providers/linkedin.js +0 -112
- package/middleware/authentication/providers/twitter.js +0 -120
- package/middleware/server-tags/server-tags.js +0 -113
- package/middleware/wcm/wcm.js +0 -1437
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -29,12 +29,45 @@ 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
|
+
// };
|
|
57
|
+
|
|
58
|
+
|
|
32
59
|
|
|
33
60
|
// by default, set up Gitana driver so that it limits to five concurrent HTTP requests back to Cloud CMS API at at time
|
|
34
61
|
var Gitana = require("gitana");
|
|
35
62
|
|
|
36
|
-
// default
|
|
37
|
-
process.
|
|
63
|
+
// default keep alive (3 minutes)
|
|
64
|
+
process.defaultKeepAliveMs = (3 * 60 * 1000);
|
|
65
|
+
|
|
66
|
+
// default http timeout (2 minutes)
|
|
67
|
+
process.defaultHttpTimeoutMs = 2 * 60 * 1000;
|
|
68
|
+
|
|
69
|
+
// default exclusive lock timeout (2 minutes)
|
|
70
|
+
process.defaultExclusiveLockTimeoutMs = 2 * 60 * 1000;
|
|
38
71
|
|
|
39
72
|
if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
40
73
|
{
|
|
@@ -51,27 +84,37 @@ if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
|
51
84
|
// dns fix for Node 17 +
|
|
52
85
|
// see: https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder
|
|
53
86
|
var dns = require("dns");
|
|
54
|
-
dns.setDefaultResultOrder
|
|
87
|
+
if (typeof(dns.setDefaultResultOrder) !== "undefined") {
|
|
88
|
+
dns.setDefaultResultOrder("ipv4first");
|
|
89
|
+
}
|
|
55
90
|
|
|
56
91
|
// default agents
|
|
57
92
|
var HttpKeepAliveAgent = require('agentkeepalive');
|
|
58
93
|
var HttpsKeepAliveAgent = require('agentkeepalive').HttpsAgent;
|
|
59
94
|
http.globalAgent = new HttpKeepAliveAgent({
|
|
60
95
|
keepAlive: true,
|
|
61
|
-
keepAliveMsecs:
|
|
62
|
-
maxSockets:
|
|
96
|
+
keepAliveMsecs: process.defaultKeepAliveMs,
|
|
97
|
+
maxSockets: 1024,
|
|
63
98
|
maxFreeSockets: 256,
|
|
64
99
|
timeout: process.defaultHttpTimeoutMs,
|
|
65
|
-
freeSocketTimeout:
|
|
100
|
+
freeSocketTimeout: 5000
|
|
66
101
|
});
|
|
67
102
|
https.globalAgent = new HttpsKeepAliveAgent({
|
|
68
103
|
keepAlive: true,
|
|
69
|
-
keepAliveMsecs:
|
|
70
|
-
maxSockets:
|
|
104
|
+
keepAliveMsecs: process.defaultKeepAliveMs,
|
|
105
|
+
maxSockets: 1024,
|
|
71
106
|
maxFreeSockets: 256,
|
|
72
107
|
timeout: process.defaultHttpTimeoutMs,
|
|
73
|
-
freeSocketTimeout:
|
|
108
|
+
freeSocketTimeout: 5000
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// install dns cache
|
|
112
|
+
const CacheableLookup = require("cacheable-lookup");
|
|
113
|
+
const cacheable = new CacheableLookup({
|
|
114
|
+
// Set any custom options here
|
|
74
115
|
});
|
|
116
|
+
cacheable.install(http.globalAgent);
|
|
117
|
+
cacheable.install(https.globalAgent);
|
|
75
118
|
|
|
76
119
|
// disable for now
|
|
77
120
|
/*
|
|
@@ -141,8 +184,8 @@ exports = module.exports = function()
|
|
|
141
184
|
// not already specified
|
|
142
185
|
var defaultGitanaProxyScheme = "https";
|
|
143
186
|
var defaultGitanaProxyHost = "api.cloudcms.com";
|
|
144
|
-
var defaultGitanaProxyPort = 443;
|
|
145
187
|
var defaultGitanaProxyPath = "";
|
|
188
|
+
var defaultGitanaProxyPort = 443;
|
|
146
189
|
|
|
147
190
|
var gitanaJsonPath = path.join(process.env.CLOUDCMS_APPSERVER_BASE_PATH, "gitana.json");
|
|
148
191
|
if (fs.existsSync(gitanaJsonPath))
|
|
@@ -153,8 +196,8 @@ exports = module.exports = function()
|
|
|
153
196
|
var parsedUrl = url.parse(gitanaJson.baseURL);
|
|
154
197
|
|
|
155
198
|
defaultGitanaProxyHost = parsedUrl.hostname;
|
|
156
|
-
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
157
199
|
defaultGitanaProxyPath = parsedUrl.path;
|
|
200
|
+
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
158
201
|
|
|
159
202
|
if (parsedUrl.port)
|
|
160
203
|
{
|
|
@@ -178,13 +221,13 @@ exports = module.exports = function()
|
|
|
178
221
|
if (!process.env.GITANA_PROXY_HOST) {
|
|
179
222
|
process.env.GITANA_PROXY_HOST = defaultGitanaProxyHost;
|
|
180
223
|
}
|
|
181
|
-
if (!process.env.GITANA_PROXY_PORT) {
|
|
182
|
-
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
183
|
-
}
|
|
184
224
|
if (!process.env.GITANA_PROXY_PATH) {
|
|
185
225
|
process.env.GITANA_PROXY_PATH = defaultGitanaProxyPath;
|
|
186
226
|
}
|
|
187
|
-
|
|
227
|
+
if (!process.env.GITANA_PROXY_PORT) {
|
|
228
|
+
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
229
|
+
}
|
|
230
|
+
|
|
188
231
|
if (cluster.isMaster)
|
|
189
232
|
{
|
|
190
233
|
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
@@ -223,13 +266,11 @@ exports = module.exports = function()
|
|
|
223
266
|
var registration = require("./middleware/registration/registration");
|
|
224
267
|
var resources = require("./middleware/resources/resources");
|
|
225
268
|
var runtime = require("./middleware/runtime/runtime");
|
|
226
|
-
var serverTags = require("./middleware/server-tags/server-tags");
|
|
227
269
|
var storeService = require("./middleware/stores/stores");
|
|
228
270
|
var templates = require("./middleware/templates/templates");
|
|
229
271
|
var themes = require("./middleware/themes/themes");
|
|
230
272
|
var virtualConfig = require("./middleware/virtual-config/virtual-config");
|
|
231
273
|
var virtualFiles = require("./middleware/virtual-files/virtual-files");
|
|
232
|
-
var wcm = require("./middleware/wcm/wcm");
|
|
233
274
|
var welcome = require("./middleware/welcome/welcome");
|
|
234
275
|
var awareness = require("./middleware/awareness/awareness");
|
|
235
276
|
var userAgent = require('express-useragent');
|
|
@@ -469,15 +510,6 @@ exports = module.exports = function()
|
|
|
469
510
|
|
|
470
511
|
// supports user-configured dynamic configuration
|
|
471
512
|
app.use(config.remoteConfigInterceptor());
|
|
472
|
-
|
|
473
|
-
// tag processing, injection of scripts, etc, kind of a catch all at the moment
|
|
474
|
-
app.use(serverTags.interceptor(configuration));
|
|
475
|
-
|
|
476
|
-
if (includeCloudCMS)
|
|
477
|
-
{
|
|
478
|
-
// handles retrieval of content from wcm
|
|
479
|
-
app.use(wcm.wcmInterceptor());
|
|
480
|
-
}
|
|
481
513
|
};
|
|
482
514
|
|
|
483
515
|
r.handlers = function(app, includeCloudCMS)
|
|
@@ -557,12 +589,6 @@ exports = module.exports = function()
|
|
|
557
589
|
// add User-Agent device info to req
|
|
558
590
|
app.use(userAgent.express());
|
|
559
591
|
|
|
560
|
-
if (includeCloudCMS)
|
|
561
|
-
{
|
|
562
|
-
// handles retrieval of content from wcm
|
|
563
|
-
app.use(wcm.wcmHandler());
|
|
564
|
-
}
|
|
565
|
-
|
|
566
592
|
// handles 404
|
|
567
593
|
app.use(final.finalHandler());
|
|
568
594
|
};
|
|
@@ -315,16 +315,11 @@ exports = module.exports = function()
|
|
|
315
315
|
registerAdapter("session", require("./adapters/session"));
|
|
316
316
|
|
|
317
317
|
// providers
|
|
318
|
-
registerProvider("cas", require("./providers/cas"));
|
|
319
|
-
registerProvider("facebook", require("./providers/facebook"));
|
|
320
|
-
registerProvider("github", require("./providers/github"));
|
|
321
318
|
registerProvider("google", require("./providers/google"));
|
|
322
319
|
registerProvider("keycloak", require("./providers/keycloak"));
|
|
323
|
-
registerProvider("linkedin", require("./providers/linkedin"));
|
|
324
320
|
registerProvider("local", require("./providers/local"));
|
|
325
321
|
registerProvider("saml", require("./providers/saml"));
|
|
326
322
|
registerProvider("trusted", require("./providers/trusted"));
|
|
327
|
-
registerProvider("twitter", require("./providers/twitter"));
|
|
328
323
|
|
|
329
324
|
// authenticators
|
|
330
325
|
registerAuthenticator("default", require("./authenticators/default"));
|
|
@@ -361,7 +356,7 @@ exports = module.exports = function()
|
|
|
361
356
|
};
|
|
362
357
|
}
|
|
363
358
|
|
|
364
|
-
console.log("Auth Callback failed, err: " + JSON.stringify(err));
|
|
359
|
+
console.log("Auth Callback failed, err: " + err + ", err json: " + JSON.stringify(err));
|
|
365
360
|
|
|
366
361
|
if (err.message)
|
|
367
362
|
{
|
|
@@ -390,13 +385,19 @@ exports = module.exports = function()
|
|
|
390
385
|
|
|
391
386
|
return function (err, profile, info) {
|
|
392
387
|
|
|
388
|
+
if (err) {
|
|
389
|
+
console.log("Caught error on auth callback function: ", err, JSON.stringify(err));
|
|
390
|
+
}
|
|
391
|
+
|
|
393
392
|
if (err) {
|
|
394
393
|
return handleFailure(err, res);
|
|
395
394
|
}
|
|
396
395
|
|
|
397
396
|
if (!profile || !info)
|
|
398
397
|
{
|
|
399
|
-
return handleFailure(
|
|
398
|
+
return handleFailure({
|
|
399
|
+
"message": "Authentication callback missing both profile and info"
|
|
400
|
+
}, res);
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
// store these onto request
|
|
@@ -695,11 +696,11 @@ exports = module.exports = function()
|
|
|
695
696
|
return function(req, res, next) {
|
|
696
697
|
|
|
697
698
|
// record filter start time
|
|
698
|
-
var _auth_filter_start_ms =
|
|
699
|
+
var _auth_filter_start_ms = Date.now();
|
|
699
700
|
|
|
700
701
|
fn(req, res, function(result, authenticator) {
|
|
701
702
|
|
|
702
|
-
var _auth_filter_end_ms =
|
|
703
|
+
var _auth_filter_end_ms = Date.now() - _auth_filter_start_ms;
|
|
703
704
|
|
|
704
705
|
util.setHeader(res, "x-cloudcms-auth-filter-ms", _auth_filter_end_ms);
|
|
705
706
|
|
|
@@ -736,8 +737,11 @@ exports = module.exports = function()
|
|
|
736
737
|
};
|
|
737
738
|
}
|
|
738
739
|
|
|
739
|
-
if (result.
|
|
740
|
-
|
|
740
|
+
if (!result.skip)
|
|
741
|
+
{
|
|
742
|
+
if (result.err && result.err.message) {
|
|
743
|
+
req.log("Auth strategy: " + strategyId + " - filter error: " + result.err.message);
|
|
744
|
+
}
|
|
741
745
|
}
|
|
742
746
|
|
|
743
747
|
var providerId = null;
|
|
@@ -810,7 +814,31 @@ exports = module.exports = function()
|
|
|
810
814
|
}
|
|
811
815
|
redirectUrl += "requested_url=" + requested_url;
|
|
812
816
|
|
|
813
|
-
|
|
817
|
+
res.status(200);
|
|
818
|
+
res.type("text/html");
|
|
819
|
+
|
|
820
|
+
// serve back a redirect via html
|
|
821
|
+
var html = " \
|
|
822
|
+
<html> \
|
|
823
|
+
<head> \
|
|
824
|
+
<script> \
|
|
825
|
+
var _redirectUrl = '" + redirectUrl + "'; \
|
|
826
|
+
var hash = window.location.hash ? window.location.hash : ''; \
|
|
827
|
+
if (hash && hash.indexOf('#') === 0) { \
|
|
828
|
+
hash = hash.substring(1); \
|
|
829
|
+
} \
|
|
830
|
+
if (hash) { \
|
|
831
|
+
_redirectUrl += '&requested_hash=' + hash; \
|
|
832
|
+
} \
|
|
833
|
+
window.location.href = _redirectUrl; \
|
|
834
|
+
</script> \
|
|
835
|
+
</head> \
|
|
836
|
+
</html> \
|
|
837
|
+
";
|
|
838
|
+
res.send(html);
|
|
839
|
+
return;
|
|
840
|
+
|
|
841
|
+
//return res.redirect(redirectUrl);
|
|
814
842
|
}
|
|
815
843
|
else if (loginHandler)
|
|
816
844
|
{
|
|
@@ -57,10 +57,14 @@ class SAMLProvider extends AbstractProvider
|
|
|
57
57
|
samlConfig.entryPoint = config.entryPoint;
|
|
58
58
|
}
|
|
59
59
|
if (config.cert) {
|
|
60
|
-
samlConfig.
|
|
60
|
+
samlConfig.idpCert = config.cert;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var callbackUrl = config.callbackURL;
|
|
63
|
+
if (!callbackUrl) {
|
|
64
|
+
callbackUrl = config.callbackUrl;
|
|
65
|
+
}
|
|
66
|
+
if (callbackUrl) {
|
|
67
|
+
samlConfig.callbackUrl = "http://localhost:5000" + callbackUrl;
|
|
64
68
|
}
|
|
65
69
|
if (config.issuer) {
|
|
66
70
|
samlConfig.issuer = config.issuer;
|
|
@@ -359,50 +359,6 @@ module.exports = function(configStore)
|
|
|
359
359
|
|
|
360
360
|
// all done
|
|
361
361
|
callback(null, registry);
|
|
362
|
-
|
|
363
|
-
var _watchLog = function(text) {
|
|
364
|
-
process.log("[Configuration Watch] " + text);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
if (process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === "true" || process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === true)
|
|
368
|
-
{
|
|
369
|
-
_watchLog("Setting up live watch...");
|
|
370
|
-
|
|
371
|
-
// set a watch
|
|
372
|
-
// watch for changes and when they happen, reload context
|
|
373
|
-
(function (registry) {
|
|
374
|
-
|
|
375
|
-
configStore.watchDirectory("/", function () {
|
|
376
|
-
|
|
377
|
-
_watchLog("Detected changes on disk - reloading...");
|
|
378
|
-
|
|
379
|
-
var t1 = new Date().getTime();
|
|
380
|
-
|
|
381
|
-
// reload context
|
|
382
|
-
loadContext(function (err, context) {
|
|
383
|
-
|
|
384
|
-
if (err) {
|
|
385
|
-
return _watchLog("Failed to load configuration context: " + err);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
try
|
|
389
|
-
{
|
|
390
|
-
compileContextToRegistry(context);
|
|
391
|
-
registry.reloadContext(context);
|
|
392
|
-
|
|
393
|
-
var t2 = new Date().getTime();
|
|
394
|
-
_watchLog("Reloaded context in: " + (t2 - t1) + " ms");
|
|
395
|
-
}
|
|
396
|
-
catch (e)
|
|
397
|
-
{
|
|
398
|
-
_watchLog("Caught error while compiling and reloading context: " + err);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
})(registry);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
362
|
});
|
|
407
363
|
};
|
|
408
364
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var util = require("../../util/util");
|
|
2
|
-
var duster = require("../../duster/index");
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Deployment middleware.
|
|
@@ -299,10 +298,6 @@ exports = module.exports = function()
|
|
|
299
298
|
logFn("Invalidating application cache for application: " + descriptor.application.id);
|
|
300
299
|
process.cache.invalidateCacheForApp(descriptor.application.id);
|
|
301
300
|
|
|
302
|
-
// invalidate "duster" cache for this application
|
|
303
|
-
logFn("Invalidating duster cache for application: " + descriptor.application.id);
|
|
304
|
-
duster.invalidateCacheForApp(descriptor.application.id);
|
|
305
|
-
|
|
306
301
|
// invalidate gitana driver for this application
|
|
307
302
|
process.broadcast.publish("application_invalidation", {
|
|
308
303
|
"applicationId": descriptor.application.id,
|
|
@@ -348,36 +343,39 @@ exports = module.exports = function()
|
|
|
348
343
|
var rootStore = stores.root;
|
|
349
344
|
rootStore.allocated(function(allocated) {
|
|
350
345
|
|
|
346
|
+
console.log("H2: " + allocated);
|
|
351
347
|
if (!allocated) {
|
|
352
|
-
|
|
348
|
+
callback({
|
|
353
349
|
"message": "The application cannot be started because it is not deployed."
|
|
354
350
|
});
|
|
355
351
|
}
|
|
352
|
+
else
|
|
353
|
+
{
|
|
354
|
+
rootStore.readFile("descriptor.json", function (err, data) {
|
|
356
355
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return callback(err);
|
|
361
|
-
}
|
|
356
|
+
if (err) {
|
|
357
|
+
return callback(err);
|
|
358
|
+
}
|
|
362
359
|
|
|
363
|
-
|
|
360
|
+
data = JSON.parse(data);
|
|
364
361
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
362
|
+
// is it already started?
|
|
363
|
+
if (data.active) {
|
|
364
|
+
return callback({
|
|
365
|
+
"message": "The application is already started"
|
|
366
|
+
});
|
|
367
|
+
}
|
|
371
368
|
|
|
372
|
-
|
|
369
|
+
data.active = true;
|
|
373
370
|
|
|
374
|
-
|
|
371
|
+
logFn("Starting application: " + data.application.id + " with host: " + host);
|
|
375
372
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
rootStore.writeFile("descriptor.json", JSON.stringify(data, null, " "), function (err) {
|
|
374
|
+
console.log("Start error: "+ err);
|
|
375
|
+
callback(err);
|
|
376
|
+
});
|
|
379
377
|
});
|
|
380
|
-
}
|
|
378
|
+
}
|
|
381
379
|
});
|
|
382
380
|
});
|
|
383
381
|
});
|
|
@@ -3,6 +3,8 @@ var http = require('http');
|
|
|
3
3
|
var util = require("../../util/util");
|
|
4
4
|
var async = require("async");
|
|
5
5
|
|
|
6
|
+
var Loaders = require("../../util/loaders");
|
|
7
|
+
|
|
6
8
|
var Gitana = require("gitana");
|
|
7
9
|
|
|
8
10
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -38,6 +40,27 @@ exports = module.exports = function()
|
|
|
38
40
|
var r = {};
|
|
39
41
|
|
|
40
42
|
var doConnect = r.doConnect = function(req, gitanaConfig, callback)
|
|
43
|
+
{
|
|
44
|
+
var key = JSON.stringify(gitanaConfig);
|
|
45
|
+
|
|
46
|
+
var loader = function(req, gitanaConfig)
|
|
47
|
+
{
|
|
48
|
+
return function(cb)
|
|
49
|
+
{
|
|
50
|
+
_doConnect(req, gitanaConfig, function(err) {
|
|
51
|
+
cb.call(this, err);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}(req, gitanaConfig);
|
|
55
|
+
|
|
56
|
+
var exclusiveLoader = Loaders.exclusive(loader, key, process.defaultExclusiveLockTimeoutMs);
|
|
57
|
+
|
|
58
|
+
exclusiveLoader(function(err) {
|
|
59
|
+
callback.call(this, err);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var _doConnect = function(req, gitanaConfig, callback)
|
|
41
64
|
{
|
|
42
65
|
// either connect anew or re-use an existing connection to Cloud CMS for this application
|
|
43
66
|
Gitana.connect(gitanaConfig, function(err) {
|
|
@@ -45,7 +68,7 @@ exports = module.exports = function()
|
|
|
45
68
|
if (err)
|
|
46
69
|
{
|
|
47
70
|
// log as much as we can
|
|
48
|
-
if(process.env.NODE_ENV === "production")
|
|
71
|
+
if (process.env.NODE_ENV === "production")
|
|
49
72
|
{
|
|
50
73
|
console.warn("Error connecting driver (domainHost=" + req.domainHost + ", virtualHost: " + req.virtualHost + ", err: " + JSON.stringify(err));
|
|
51
74
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var http = require('http');
|
|
4
1
|
var util = require("../../util/util");
|
|
5
|
-
var Gitana = require("gitana");
|
|
6
|
-
var duster = require("../../duster/index");
|
|
7
2
|
var async = require("async");
|
|
8
3
|
var auth = require("../../util/auth");
|
|
9
4
|
|
|
@@ -84,10 +84,6 @@ exports = module.exports = function(engineId, engineType, engineConfig)
|
|
|
84
84
|
callback(null, null); //data
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
88
|
-
{
|
|
89
|
-
};
|
|
90
|
-
|
|
91
87
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
92
88
|
{
|
|
93
89
|
callback(null);
|
|
@@ -442,11 +442,6 @@ exports = module.exports = function(remoteStore, settings)
|
|
|
442
442
|
cacheStore.readFile(filePath, callback);
|
|
443
443
|
};
|
|
444
444
|
|
|
445
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
446
|
-
{
|
|
447
|
-
// NOT IMPLEMENTED
|
|
448
|
-
};
|
|
449
|
-
|
|
450
445
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
451
446
|
{
|
|
452
447
|
remoteStore.moveFile(originalFilePath, newFilePath, function(err) {
|
|
@@ -4,8 +4,6 @@ var http = require('http');
|
|
|
4
4
|
|
|
5
5
|
var util = require("../../../util/util");
|
|
6
6
|
|
|
7
|
-
var watch = require("watch");
|
|
8
|
-
|
|
9
7
|
var async = require("async");
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -217,13 +215,6 @@ exports = module.exports = function(engineConfig)
|
|
|
217
215
|
});
|
|
218
216
|
};
|
|
219
217
|
|
|
220
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
221
|
-
{
|
|
222
|
-
watch.watchTree(toStoragePath(directoryPath), function(f, curr, prev) {
|
|
223
|
-
onChange(f, curr, prev);
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
|
|
227
218
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
228
219
|
{
|
|
229
220
|
fs.rename(toStoragePath(originalFilePath), newFilePath, function(err) {
|
|
@@ -406,11 +406,6 @@ exports = module.exports = function(engineConfig)
|
|
|
406
406
|
});
|
|
407
407
|
};
|
|
408
408
|
|
|
409
|
-
// NOT IMPLEMENTED IN S3
|
|
410
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
411
|
-
{
|
|
412
|
-
};
|
|
413
|
-
|
|
414
409
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
415
410
|
{
|
|
416
411
|
var originalKey = _toKey(originalFilePath);
|
|
@@ -79,11 +79,6 @@ exports = module.exports = function(engineConfig)
|
|
|
79
79
|
cachingAdapter.readFile(filePath, callback);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
83
|
-
{
|
|
84
|
-
cachingAdapter.watchDirectory(directoryPath, onChange);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
82
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
88
83
|
{
|
|
89
84
|
cachingAdapter.moveFile(originalFilePath, newFilePath, callback);
|
|
@@ -283,35 +283,6 @@ exports = module.exports = function(originalStores)
|
|
|
283
283
|
});
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
287
|
-
{
|
|
288
|
-
findFileStores(directoryPath, function(err, stores) {
|
|
289
|
-
|
|
290
|
-
if (err) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (stores.length === 0) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
var fns = [];
|
|
299
|
-
for (var i = 0; i < stores.length; i++)
|
|
300
|
-
{
|
|
301
|
-
var fn = function(s, directoryPath) {
|
|
302
|
-
return function(done) {
|
|
303
|
-
s.watchDirectory(directoryPath, onChange);
|
|
304
|
-
done();
|
|
305
|
-
}
|
|
306
|
-
}(stores[i], directoryPath);
|
|
307
|
-
fns.push(fn);
|
|
308
|
-
}
|
|
309
|
-
async.series(fns, function() {
|
|
310
|
-
// done
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
|
|
315
286
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
316
287
|
{
|
|
317
288
|
// TODO: not implemented
|
|
@@ -238,15 +238,6 @@ exports = module.exports = function(engine, engineType, engineId, engineConfigur
|
|
|
238
238
|
});
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
-
r.watchDirectory = function(directoryPath, onChange)
|
|
242
|
-
{
|
|
243
|
-
debugStart("Start store.watchDirectory: " + _enginePath(directoryPath));
|
|
244
|
-
engine.watchDirectory(_enginePath(directoryPath), function(f, curr, prev) {
|
|
245
|
-
debugFinish("Finish store.watchDirectory");
|
|
246
|
-
onChange(f, curr, prev);
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
|
|
250
241
|
r.moveFile = function(originalFilePath, newFilePath, callback)
|
|
251
242
|
{
|
|
252
243
|
debugStart("Start store.moveFile");
|