update deps and add a bunch of debug logging
This commit is contained in:
parent
25e644bb5d
commit
e855e159f9
|
@ -71,6 +71,7 @@ cluster.on('online', function (worker) {
|
|||
// calls init if init has not been called
|
||||
require('../lib/master').touch(info.conf, state).then(function (newConf) {
|
||||
worker.send({ type: 'walnut.webserver.onrequest', conf: newConf });
|
||||
newConf.addWorker(worker);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -46,13 +46,20 @@ function init(conf, state) {
|
|||
|
||||
var cstore = require('cluster-store');
|
||||
var sqlite3 = require('sqlite3-cluster/server');
|
||||
var cstoreOpts = {
|
||||
sock: conf.memstoreSock
|
||||
, serve: cluster.isMaster && conf.memstoreSock
|
||||
, store: cluster.isMaster && null //new require('express-session/session/memory')()
|
||||
// TODO implement
|
||||
, key: conf.ipcKey
|
||||
};
|
||||
var cstorePromise = cstore.create(cstoreOpts);
|
||||
var promise = PromiseA.all([
|
||||
cstore.create({
|
||||
sock: conf.memstoreSock
|
||||
, serve: cluster.isMaster && conf.memstoreSock
|
||||
, store: cluster.isMaster && null //new require('express-session/session/memory')()
|
||||
// TODO implement
|
||||
, key: conf.ipcKey
|
||||
cstorePromise.then(function (store) {
|
||||
console.log('[walnut] [master] cstore created');
|
||||
//console.log(cstoreOpts);
|
||||
//console.log(store);
|
||||
return store;
|
||||
})
|
||||
, sqlite3.createServer({
|
||||
verbose: null
|
||||
|
@ -65,6 +72,9 @@ function init(conf, state) {
|
|||
]).then(function (args) {
|
||||
state.memstore = args[0];
|
||||
//state.sqlstore = args[1];
|
||||
newConf.addWorker = function (w) {
|
||||
return cstorePromise.addWorker(w);
|
||||
};
|
||||
return newConf;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports.create = function (webserver, xconfx, state) {
|
||||
console.log('[worker] create');
|
||||
xconfx.debug = true;
|
||||
console.log('DEBUG create worker');
|
||||
|
||||
if (!state) {
|
||||
|
@ -35,6 +37,7 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
*/
|
||||
var cstore = require('cluster-store');
|
||||
|
||||
console.log('[worker] creating data stores...');
|
||||
return PromiseA.all([
|
||||
// TODO security on memstore
|
||||
// TODO memstoreFactory.create
|
||||
|
@ -44,6 +47,7 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
// TODO implement
|
||||
, key: xconfx.ipcKey
|
||||
}).then(function (_memstore) {
|
||||
console.log('[worker] cstore created');
|
||||
memstore = PromiseA.promisifyAll(_memstore);
|
||||
return memstore;
|
||||
})
|
||||
|
@ -52,8 +56,12 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
, systemFactory.create({
|
||||
init: true
|
||||
, dbname: 'config'
|
||||
}).then(function (sysdb) {
|
||||
console.log('[worker] sysdb created');
|
||||
return sysdb;
|
||||
})
|
||||
]).then(function (args) {
|
||||
console.log('[worker] database factories created');
|
||||
memstore = args[0];
|
||||
sqlstores.config = args[1];
|
||||
|
||||
|
@ -70,7 +78,6 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
, indices: [ 'createdAt', 'updatedAt' ]
|
||||
}
|
||||
];
|
||||
console.log('config directive', dir);
|
||||
|
||||
function scopeMemstore(expId) {
|
||||
var scope = expId + '|';
|
||||
|
@ -120,8 +127,11 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
}
|
||||
|
||||
return wrap.wrap(sqlstores.config, dir).then(function (models) {
|
||||
console.log('[worker] database wrapped');
|
||||
return models.ComDaplieWalnutConfig.find(null, { limit: 100 }).then(function (results) {
|
||||
console.log('[worker] config query complete');
|
||||
return models.ComDaplieWalnutConfig.find(null, { limit: 10000 }).then(function (redirects) {
|
||||
console.log('[worker] configuring express');
|
||||
var express = require('express-lazy');
|
||||
var app = express();
|
||||
var recase = require('connect-recase')({
|
||||
|
@ -160,15 +170,19 @@ module.exports.create = function (webserver, xconfx, state) {
|
|||
}
|
||||
|
||||
function setupMain() {
|
||||
if (xconfx.debug) { console.log('[main] setup'); }
|
||||
mainApp = express();
|
||||
require('./main').create(mainApp, xconfx, apiFactories, apiDeps).then(function () {
|
||||
if (xconfx.debug) { console.log('[main] ready'); }
|
||||
// TODO process.send({});
|
||||
});
|
||||
}
|
||||
|
||||
if (!bootstrapApp) {
|
||||
if (xconfx.debug) { console.log('[bootstrap] setup'); }
|
||||
bootstrapApp = express();
|
||||
require('./bootstrap').create(bootstrapApp, xconfx, models).then(function () {
|
||||
if (xconfx.debug) { console.log('[bootstrap] ready'); }
|
||||
// TODO process.send({});
|
||||
setupMain();
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"body-parser": "1.x",
|
||||
"btoa": "1.x",
|
||||
"bytes": "^1.0.0",
|
||||
"cluster-store": "git+https://git.daplie.com/coolaj86/cluster-store.git",
|
||||
"cluster-store": "git+https://git.daplie.com/Daplie/cluster-store.git#v2",
|
||||
"compression": "1.x",
|
||||
"connect": "3.x",
|
||||
"connect-cors": "0.5.x",
|
||||
|
|
Loading…
Reference in New Issue