This commit is contained in:
Dominic Bosch 2014-03-20 09:16:56 +01:00
commit a5ed804bb1
21 changed files with 1289 additions and 1116 deletions

View file

@ -50,13 +50,13 @@ loadConfigFile = ( configPath ) =>
#TODO Try to get rid of crypto key #TODO Try to get rid of crypto key
try try
@config = JSON.parse fs.readFileSync path.resolve __dirname, '..', configPath @config = JSON.parse fs.readFileSync path.resolve __dirname, '..', configPath
isReady = true @isReady = true
for prop in confProperties for prop in confProperties
if !@config[prop] if !@config[prop]
isReady = false @isReady = false
if not isReady and not @nolog if not @isReady and not @nolog
console.error """Missing property in config file, requires: console.error "Missing property in config file, requires:\n" +
- #{ confProperties.join "\n -" }""" " - #{ confProperties.join "\n - " }"
catch e catch e
if not @nolog if not @nolog
console.error "Failed loading config file: #{ e.message }" console.error "Failed loading config file: #{ e.message }"
@ -75,7 +75,7 @@ fetchProp = ( prop ) => @config?[prop]
@public isReady() @public isReady()
### ###
exports.isReady = => @config? exports.isReady = => @isReady
### ###
***Returns*** the HTTP port ***Returns*** the HTTP port

View file

@ -231,7 +231,9 @@ class IndexedModules
@log.info "DB | storeModule(#{ @setname }): #{ mId }" @log.info "DB | storeModule(#{ @setname }): #{ mId }"
@db.sadd "#{ @setname }s", mId, @db.sadd "#{ @setname }s", mId,
replyHandler "Storing '#{ @setname }' key '#{ mId }'" replyHandler "Storing '#{ @setname }' key '#{ mId }'"
@db.hmset "#{ @setname }:#{ mId }", data, @db.hmset "#{ @setname }:#{ mId }", 'code', data['code'],
replyHandler "Storing '#{ @setname }:#{ mId }'"
@db.hmset "#{ @setname }:#{ mId }", 'reqparams', data['reqparams'],
replyHandler "Storing '#{ @setname }:#{ mId }'" replyHandler "Storing '#{ @setname }:#{ mId }'"
#TODO add testing #TODO add testing

View file

@ -106,6 +106,7 @@ init = =>
process.exit() process.exit()
logconf = conf.getLogConf() logconf = conf.getLogConf()
if argv.m if argv.m
logconf[ 'mode' ] = argv.m logconf[ 'mode' ] = argv.m
if argv.i if argv.i
@ -145,11 +146,17 @@ init = =>
# Start the event poller. The module manager will emit events for it # Start the event poller. The module manager will emit events for it
@log.info 'RS | Forking a child process for the event poller' @log.info 'RS | Forking a child process for the event poller'
# Grab all required log config fields
cliArgs = [ cliArgs = [
# the log mode: [development|productive]
args.logconf['mode'] args.logconf['mode']
# the I/O log level, refer to logging.coffee for the different levels
args.logconf['io-level'] args.logconf['io-level']
# the file log level, refer to logging.coffee for the different levels
args.logconf['file-level'] args.logconf['file-level']
# the optional path to the log file
args.logconf['file-path'] args.logconf['file-path']
# whether a log file shall be written at all: null else
args.logconf['nolog'] args.logconf['nolog']
] ]
poller = cp.fork path.resolve( __dirname, nameEP ), cliArgs poller = cp.fork path.resolve( __dirname, nameEP ), cliArgs

View file

@ -1,6 +1,9 @@
{ {
"http_port": 8125, "http-port": 8125,
"db_port": 6379, "db-port": 6379,
"crypto_key": "[choose_a_safe_cypto_key(max_256_bit)]", "log": {
"session_secret": "[choose_a_safe_session_key]" "mode": "development",
"io-level": "info",
"file-level": "info"
}
} }

View file

@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
Components Manager Components Manager
@ -6,12 +7,10 @@ Components Manager
> The components manager takes care of the dynamic JS modules and the rules. > The components manager takes care of the dynamic JS modules and the rules.
> Event Poller and Action Invoker modules are loaded as strings and stored in the database, > Event Poller and Action Invoker modules are loaded as strings and stored in the database,
> then compiled into node modules and rules and used in the engine and event poller. > then compiled into node modules and rules and used in the engine and event poller.
*/ */
(function() { (function() {
var commandFunctions, db, dynmod, events, exports, fs, path, vm, var commandFunctions, db, dynmod, events, exports, fs, path, vm;
_this = this;
db = require('./persistence'); db = require('./persistence');
@ -25,86 +24,94 @@ Components Manager
events = require('events'); events = require('events');
/* /*
Module call Module call
----------- -----------
Initializes the HTTP listener and its request handler. Initializes the HTTP listener and its request handler.
@param {Object} args @param {Object} args
*/ */
exports = module.exports = (function(_this) {
return function(args) {
_this.log = args.logger;
_this.ee = new events.EventEmitter();
db(args);
dynmod(args);
return module.exports;
};
})(this);
exports = module.exports = function(args) { exports.addListener = (function(_this) {
_this.log = args.logger; return function(evt, eh) {
_this.ee = new events.EventEmitter(); _this.ee.addListener(evt, eh);
db(args); return db.getRules(function(err, obj) {
dynmod(args); var id, rule, _results;
return module.exports; _results = [];
}; for (id in obj) {
rule = obj[id];
exports.addListener = function(evt, eh) { _results.push(_this.ee.emit('init', rule));
_this.ee.addListener(evt, eh); }
return db.getRules(function(err, obj) { return _results;
var id, rule, _results;
_results = [];
for (id in obj) {
rule = obj[id];
_results.push(_this.ee.emit('init', rule));
}
return _results;
});
};
exports.processRequest = function(user, obj, cb) {
var answ;
if (commandFunctions[obj.command]) {
return answ = commandFunctions[obj.command](user, obj, cb);
} else {
return cb({
code: 404,
message: 'Strange request!'
}); });
} };
}; })(this);
exports.processRequest = (function(_this) {
return function(user, obj, cb) {
var answ;
if (commandFunctions[obj.command]) {
return answ = commandFunctions[obj.command](user, obj, cb);
} else {
return cb({
code: 404,
message: 'Strange request!'
});
}
};
})(this);
commandFunctions = { commandFunctions = {
forge_event_poller: function(user, obj, cb) { forge_event_poller: (function(_this) {
var answ; return function(user, obj, cb) {
answ = { var answ;
code: 200 answ = {
}; code: 200
return db.getEventPoller(obj.id, function(err, mod) { };
var cm, id, name, src, _ref; return db.getEventPoller(obj.id, function(err, mod) {
if (mod) { var cm, id, name, src, _ref;
answ.code = 409; if (mod) {
answ.message = 'Event Poller module name already existing: ' + obj.id; answ.code = 409;
} else { answ.message = 'Event Poller module name already existing: ' + obj.id;
src = obj.data; } else {
cm = dynmod.compileString(src, obj.id, {}, obj.lang); src = obj.data;
answ = cm.answ; cm = dynmod.compileString(src, obj.id, {}, obj.lang);
if (answ.code === 200) { answ = cm.answ;
events = []; if (answ.code === 200) {
_ref = cm.module; events = [];
for (name in _ref) { _ref = cm.module;
id = _ref[name]; for (name in _ref) {
events.push(name); id = _ref[name];
} events.push(name);
_this.log.info("CM | Storing new eventpoller with events " + events); }
answ.message = "Event Poller module successfully stored! Found following event(s): " + events; _this.log.info("CM | Storing new eventpoller with events " + events);
db.storeEventPoller(obj.id, user.username, { answ.message = "Event Poller module successfully stored! Found following event(s): " + events;
code: obj.data, db.storeEventPoller(obj.id, user.username, {
lang: obj.lang, code: obj.data,
params: obj.params, lang: obj.lang,
events: events params: obj.params,
}); events: events
if (obj["public"] === 'true') { });
db.publishEventPoller(obj.id); if (obj["public"] === 'true') {
db.publishEventPoller(obj.id);
}
} }
} }
} return cb(answ);
return cb(answ); });
}); };
}, })(this),
get_event_pollers: function(user, obj, cb) { get_event_pollers: function(user, obj, cb) {
return db.getAvailableEventPollerIds(user.username, function(err, obj) { return db.getAvailableEventPollerIds(user.username, function(err, obj) {
var fGetEvents, id, oRes, sem, _i, _len, _results; var fGetEvents, id, oRes, sem, _i, _len, _results;
@ -169,80 +176,84 @@ Components Manager
}); });
}); });
}, },
forge_action_invoker: function(user, obj, cb) { forge_action_invoker: (function(_this) {
var answ; return function(user, obj, cb) {
answ = { var answ;
code: 200 answ = {
}; code: 200
return db.getActionInvoker(obj.id, function(err, mod) { };
var actions, cm, id, name, src, _ref; return db.getActionInvoker(obj.id, function(err, mod) {
if (mod) { var actions, cm, id, name, src, _ref;
answ.code = 409; if (mod) {
answ.message = 'Action Invoker module name already existing: ' + obj.id; answ.code = 409;
} else { answ.message = 'Action Invoker module name already existing: ' + obj.id;
src = obj.data; } else {
cm = dynmod.compileString(src, obj.id, {}, obj.lang); src = obj.data;
answ = cm.answ; cm = dynmod.compileString(src, obj.id, {}, obj.lang);
if (answ.code === 200) { answ = cm.answ;
actions = []; if (answ.code === 200) {
_ref = cm.module; actions = [];
for (name in _ref) { _ref = cm.module;
id = _ref[name]; for (name in _ref) {
actions.push(name); id = _ref[name];
} actions.push(name);
_this.log.info("CM | Storing new eventpoller with actions " + actions); }
answ.message = "Action Invoker module successfully stored! Found following action(s): " + actions; _this.log.info("CM | Storing new eventpoller with actions " + actions);
db.storeActionInvoker(obj.id, user.username, { answ.message = "Action Invoker module successfully stored! Found following action(s): " + actions;
code: obj.data, db.storeActionInvoker(obj.id, user.username, {
lang: obj.lang, code: obj.data,
params: obj.params, lang: obj.lang,
actions: actions params: obj.params,
}); actions: actions
if (obj["public"] === 'true') { });
db.publishActionInvoker(obj.id); if (obj["public"] === 'true') {
db.publishActionInvoker(obj.id);
}
} }
} }
} return cb(answ);
return cb(answ); });
}); };
}, })(this),
get_rules: function(user, obj, cb) { get_rules: function(user, obj, cb) {
return console.log('CM | Implement get_rules'); return console.log('CM | Implement get_rules');
}, },
forge_rule: function(user, obj, cb) { forge_rule: (function(_this) {
obj.event = JSON.parse(obj.event); return function(user, obj, cb) {
return db.getRule(obj.id, function(err, objRule) { obj.event = JSON.parse(obj.event);
var answ, id, modules, params, rule; return db.getRule(obj.id, function(err, objRule) {
if (objRule !== null) { var answ, id, modules, params, rule;
answ = { if (objRule !== null) {
code: 409, answ = {
message: 'Rule name already existing!' code: 409,
}; message: 'Rule name already existing!'
} else { };
answ = { } else {
code: 200, answ = {
message: 'Rule stored and activated!' code: 200,
}; message: 'Rule stored and activated!'
rule = { };
id: obj.id, rule = {
event: "" + obj.event.module + " -> " + obj.event["function"], id: obj.id,
conditions: JSON.parse(obj.conditions), event: "" + obj.event.module + " -> " + obj.event["function"],
actions: JSON.parse(obj.actions) conditions: JSON.parse(obj.conditions),
}; actions: JSON.parse(obj.actions)
modules = JSON.parse(obj.action_params); };
db.storeRule(rule.id, JSON.stringify(rule)); modules = JSON.parse(obj.action_params);
db.linkRule(rule.id, user.username); db.storeRule(rule.id, JSON.stringify(rule));
db.activateRule(rule.id, user.username); db.linkRule(rule.id, user.username);
db.storeEventUserParams(obj.event.module, user.username, obj.event_params); db.activateRule(rule.id, user.username);
for (id in modules) { db.storeEventUserParams(obj.event.module, user.username, obj.event_params);
params = modules[id]; for (id in modules) {
db.storeActionUserParams(id, user.username, JSON.stringify(params)); params = modules[id];
db.storeActionUserParams(id, user.username, JSON.stringify(params));
}
_this.ee.emit('newRule', JSON.stringify(rule));
} }
_this.ee.emit('newRule', JSON.stringify(rule)); return cb(answ);
} });
return cb(answ); };
}); })(this)
}
}; };
}).call(this); }).call(this);

View file

@ -1,20 +1,20 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
Configuration Configuration
============= =============
> Loads the configuration file and acts as an interface to it. > Loads the configuration file and acts as an interface to it.
*/ */
(function() { (function() {
var exports, fetchProp, fs, loadConfigFile, path, var exports, fetchProp, fs, loadConfigFile, path;
_this = this;
fs = require('fs'); fs = require('fs');
path = require('path'); path = require('path');
/* /*
Module call Module call
----------- -----------
@ -24,21 +24,23 @@ Configuration
be generated) and configPath for a custom configuration file path. be generated) and configPath for a custom configuration file path.
@param {Object} args @param {Object} args
*/ */
exports = module.exports = (function(_this) {
return function(args) {
args = args != null ? args : {};
if (args.nolog) {
_this.nolog = true;
}
if (args.configPath) {
loadConfigFile(args.configPath);
} else {
loadConfigFile(path.join('config', 'config.json'));
}
return module.exports;
};
})(this);
exports = module.exports = function(args) {
args = args != null ? args : {};
if (args.nolog) {
_this.nolog = true;
}
if (args.configPath) {
loadConfigFile(args.configPath);
} else {
loadConfigFile(path.join('config', 'config.json'));
}
return module.exports;
};
/* /*
Tries to load a configuration file from the path relative to this module's parent folder. Tries to load a configuration file from the path relative to this module's parent folder.
@ -46,96 +48,101 @@ Configuration
@private loadConfigFile @private loadConfigFile
@param {String} configPath @param {String} configPath
*/ */
loadConfigFile = (function(_this) {
loadConfigFile = function(configPath) { return function(configPath) {
var confProperties, e, isReady, prop, _i, _len; var confProperties, e, prop, _i, _len;
_this.config = null; _this.config = null;
confProperties = ['log', 'http-port', 'db-port']; confProperties = ['log', 'http-port', 'db-port'];
try { try {
_this.config = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', configPath))); _this.config = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', configPath)));
isReady = true; _this.isReady = true;
for (_i = 0, _len = confProperties.length; _i < _len; _i++) { for (_i = 0, _len = confProperties.length; _i < _len; _i++) {
prop = confProperties[_i]; prop = confProperties[_i];
if (!_this.config[prop]) { if (!_this.config[prop]) {
isReady = false; _this.isReady = false;
}
}
if (!_this.isReady && !_this.nolog) {
return console.error("Missing property in config file, requires:\n" + (" - " + (confProperties.join("\n - "))));
}
} catch (_error) {
e = _error;
if (!_this.nolog) {
return console.error("Failed loading config file: " + e.message);
} }
} }
if (!isReady && !_this.nolog) { };
return console.error("Missing property in config file, requires: \n- " + (confProperties.join("\n -"))); })(this);
}
} catch (_error) {
e = _error;
if (!_this.nolog) {
return console.error("Failed loading config file: " + e.message);
}
}
};
/* /*
Fetch a property from the configuration Fetch a property from the configuration
@private fetchProp( *prop* ) @private fetchProp( *prop* )
@param {String} prop @param {String} prop
*/ */
fetchProp = (function(_this) {
return function(prop) {
var _ref;
return (_ref = _this.config) != null ? _ref[prop] : void 0;
};
})(this);
fetchProp = function(prop) {
var _ref;
return (_ref = _this.config) != null ? _ref[prop] : void 0;
};
/* /*
***Returns*** true if the config file is ready, else false ***Returns*** true if the config file is ready, else false
@public isReady() @public isReady()
*/ */
exports.isReady = (function(_this) {
return function() {
return _this.isReady;
};
})(this);
exports.isReady = function() {
return _this.config != null;
};
/* /*
***Returns*** the HTTP port ***Returns*** the HTTP port
@public getHttpPort() @public getHttpPort()
*/ */
exports.getHttpPort = function() { exports.getHttpPort = function() {
return fetchProp('http-port'); return fetchProp('http-port');
}; };
/* /*
***Returns*** the DB port* ***Returns*** the DB port*
@public getDBPort() @public getDBPort()
*/ */
exports.getDbPort = function() { exports.getDbPort = function() {
return fetchProp('db-port'); return fetchProp('db-port');
}; };
/* /*
***Returns*** the log conf object ***Returns*** the log conf object
@public getLogConf() @public getLogConf()
*/ */
exports.getLogConf = function() { exports.getLogConf = function() {
return fetchProp('log'); return fetchProp('log');
}; };
/* /*
***Returns*** the crypto key ***Returns*** the crypto key
@public getCryptoKey() @public getCryptoKey()
*/ */
exports.getCryptoKey = function() { exports.getCryptoKey = function() {
return fetchProp('crypto-key'); return fetchProp('crypto-key');

View file

@ -1,16 +1,15 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
Dynamic Modules Dynamic Modules
=============== ===============
> Compiles CoffeeScript modules and loads JS modules in a VM, together > Compiles CoffeeScript modules and loads JS modules in a VM, together
> with only a few allowed node.js modules. > with only a few allowed node.js modules.
*/ */
(function() { (function() {
var cs, exports, needle, vm, var cs, exports, needle, vm;
_this = this;
vm = require('vm'); vm = require('vm');
@ -18,19 +17,22 @@ Dynamic Modules
cs = require('coffee-script'); cs = require('coffee-script');
/* /*
Module call Module call
----------- -----------
Initializes the dynamic module handler. Initializes the dynamic module handler.
@param {Object} args @param {Object} args
*/ */
exports = module.exports = (function(_this) {
return function(args) {
_this.log = args.logger;
return module.exports;
};
})(this);
exports = module.exports = function(args) {
_this.log = args.logger;
return module.exports;
};
/* /*
Try to run a JS module from a string, together with the Try to run a JS module from a string, together with the
@ -42,44 +44,45 @@ Dynamic Modules
@param {String} id @param {String} id
@param {Object} params @param {Object} params
@param {String} lang @param {String} lang
*/ */
exports.compileString = (function(_this) {
exports.compileString = function(src, id, params, lang) { return function(src, id, params, lang) {
var answ, err, ret, sandbox; var answ, err, ret, sandbox;
answ = { answ = {
code: 200, code: 200,
message: 'Successfully compiled' message: 'Successfully compiled'
}; };
if (lang === '0') { if (lang === '0') {
try {
src = cs.compile(src);
} catch (_error) {
err = _error;
answ.code = 400;
answ.message = 'Compilation of CoffeeScript failed at line ' + err.location.first_line;
}
}
sandbox = {
id: id,
params: params,
needle: needle,
log: console.log,
exports: {}
};
try { try {
src = cs.compile(src); vm.runInNewContext(src, sandbox, id + '.vm');
} catch (_error) { } catch (_error) {
err = _error; err = _error;
console.log(err);
answ.code = 400; answ.code = 400;
answ.message = 'Compilation of CoffeeScript failed at line ' + err.location.first_line; answ.message = 'Loading Module failed: ' + err.message;
} }
} ret = {
sandbox = { answ: answ,
id: id, module: sandbox.exports
params: params, };
needle: needle, return ret;
log: console.log,
exports: {}
}; };
try { })(this);
vm.runInNewContext(src, sandbox, id + '.vm');
} catch (_error) {
err = _error;
console.log(err);
answ.code = 400;
answ.message = 'Loading Module failed: ' + err.message;
}
ret = {
answ: answ,
module: sandbox.exports
};
return ret;
};
}).call(this); }).call(this);

View file

@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
HTTP Listener HTTP Listener
@ -6,12 +7,10 @@ HTTP Listener
> Receives the HTTP requests to the server at the given port. The requests > Receives the HTTP requests to the server at the given port. The requests
> (bound to a method) are then redirected to the appropriate handler which > (bound to a method) are then redirected to the appropriate handler which
> takes care of the request. > takes care of the request.
*/ */
(function() { (function() {
var app, exports, express, initRouting, path, qs, requestHandler, var app, exports, express, initRouting, path, qs, requestHandler;
_this = this;
requestHandler = require('./request-handler'); requestHandler = require('./request-handler');
@ -23,73 +22,77 @@ HTTP Listener
app = express(); app = express();
/* /*
Module call Module call
----------- -----------
Initializes the HTTP listener and its request handler. Initializes the HTTP listener and its request handler.
@param {Object} args @param {Object} args
*/ */
exports = module.exports = (function(_this) {
return function(args) {
_this.log = args.logger;
_this.shutDownSystem = args['shutdown-function'];
requestHandler(args);
initRouting(args['http-port']);
return module.exports;
};
})(this);
exports = module.exports = function(args) {
_this.log = args.logger;
_this.shutDownSystem = args['shutdown-function'];
requestHandler(args);
initRouting(args['http-port']);
return module.exports;
};
/* /*
Initializes the request routing and starts listening on the given port. Initializes the request routing and starts listening on the given port.
@param {int} port @param {int} port
@private initRouting( *fShutDown* ) @private initRouting( *fShutDown* )
*/ */
initRouting = (function(_this) {
return function(port) {
var server, sess_sec;
app.use(express.cookieParser());
sess_sec = "149u*y8C:@kmN/520Gt\\v'+KFBnQ!\\r<>5X/xRI`sT<Iw";
app.use(express.session({
secret: sess_sec
}));
_this.log.info('HL | no session backbone');
app.use('/', express["static"](path.resolve(__dirname, '..', 'webpages', 'public')));
app.get('/admin', requestHandler.handleAdmin);
app.get('/forge', requestHandler.handleForge);
app.post('/event', requestHandler.handleEvent);
app.post('/login', requestHandler.handleLogin);
app.post('/logout', requestHandler.handleLogout);
app.post('/usercommand', requestHandler.handleUserCommand);
app.post('/admincommand', requestHandler.handleAdminCommand);
server = app.listen(parseInt(port) || 8111);
server.on('listening', function() {
var addr;
addr = server.address();
if (addr.port !== port) {
return _this.shutDownSystem();
}
});
return server.on('error', function(err) {
initRouting = function(port) { /*
var server, sess_sec; Error handling of the express port listener requires special attention,
app.use(express.cookieParser()); thus we have to catch the error, which is issued if the port is already in use.
sess_sec = "149u*y8C:@kmN/520Gt\\v'+KFBnQ!\\r<>5X/xRI`sT<Iw"; */
app.use(express.session({ switch (err.errno) {
secret: sess_sec case 'EADDRINUSE':
})); _this.log.error(err, 'HL | http-port already in use, shutting down!');
_this.log.info('HL | no session backbone'); break;
app.use('/', express["static"](path.resolve(__dirname, '..', 'webpages', 'public'))); case 'EACCES':
app.get('/admin', requestHandler.handleAdmin); _this.log.error(err, 'HL | http-port not accessible, shutting down!');
app.get('/forge', requestHandler.handleForge); break;
app.post('/event', requestHandler.handleEvent); default:
app.post('/login', requestHandler.handleLogin); _this.log.error(err, 'HL | Error in server, shutting down!');
app.post('/logout', requestHandler.handleLogout); }
app.post('/usercommand', requestHandler.handleUserCommand);
app.post('/admincommand', requestHandler.handleAdminCommand);
server = app.listen(parseInt(port) || 8111);
server.on('listening', function() {
var addr;
addr = server.address();
if (addr.port !== port) {
return _this.shutDownSystem(); return _this.shutDownSystem();
} });
}); };
return server.on('error', function(err) { })(this);
/*
Error handling of the express port listener requires special attention,
thus we have to catch the error, which is issued if the port is already in use.
*/
switch (err.errno) {
case 'EADDRINUSE':
_this.log.error(err, 'HL | http-port already in use, shutting down!');
break;
case 'EACCES':
_this.log.error(err, 'HL | http-port not accessible, shutting down!');
break;
default:
_this.log.error(err, 'HL | Error in server, shutting down!');
}
return _this.shutDownSystem();
});
};
}).call(this); }).call(this);

View file

@ -1,7 +1,6 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var bunyan, fs, path, var bunyan, fs, path;
_this = this;
fs = require('fs'); fs = require('fs');
@ -9,64 +8,66 @@
bunyan = require('bunyan'); bunyan = require('bunyan');
/* /*
Returns a bunyan logger according to the given arguments. Returns a bunyan logger according to the given arguments.
@public getLogger( *args* ) @public getLogger( *args* )
@param {Object} args @param {Object} args
*/ */
exports.getLogger = (function(_this) {
exports.getLogger = function(args) { return function(args) {
var e, emptylog, opt; var e, emptylog, opt;
emptylog = { emptylog = {
trace: function() {}, trace: function() {},
debug: function() {}, debug: function() {},
info: function() {}, info: function() {},
warn: function() {}, warn: function() {},
error: function() {}, error: function() {},
fatal: function() {} fatal: function() {}
}; };
args = args != null ? args : {}; args = args != null ? args : {};
if (args.nolog) { if (args.nolog) {
return emptylog; return emptylog;
} else { } else {
try {
opt = {
name: "webapi-eca"
};
if (args['mode'] === 'development') {
opt.src = true;
}
if (args['file-path']) {
_this.logPath = path.resolve(args['file-path']);
} else {
_this.logPath = path.resolve(__dirname, '..', 'logs', 'server.log');
}
try { try {
fs.writeFileSync(_this.logPath + '.temp', 'temp'); opt = {
fs.unlinkSync(_this.logPath + '.temp'); name: "webapi-eca"
};
if (args['mode'] === 'development') {
opt.src = true;
}
if (args['file-path']) {
_this.logPath = path.resolve(args['file-path']);
} else {
_this.logPath = path.resolve(__dirname, '..', 'logs', 'server.log');
}
try {
fs.writeFileSync(_this.logPath + '.temp', 'temp');
fs.unlinkSync(_this.logPath + '.temp');
} catch (_error) {
e = _error;
console.error("Log folder '" + _this.logPath + "' is not writable");
return emptylog;
}
opt.streams = [
{
level: args['io-level'],
stream: process.stdout
}, {
level: args['file-level'],
path: _this.logPath
}
];
return bunyan.createLogger(opt);
} catch (_error) { } catch (_error) {
e = _error; e = _error;
console.error("Log folder '" + _this.logPath + "' is not writable"); console.error(e);
return emptylog; return emptylog;
} }
opt.streams = [
{
level: args['io-level'],
stream: process.stdout
}, {
level: args['file-level'],
path: _this.logPath
}
];
return bunyan.createLogger(opt);
} catch (_error) {
e = _error;
console.error(e);
return emptylog;
} }
} };
}; })(this);
}).call(this); }).call(this);

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
Request Handler Request Handler
@ -7,12 +8,10 @@ Request Handler
> the [HTTP Listener](http-listener.html). It will handle user requests for > the [HTTP Listener](http-listener.html). It will handle user requests for
> pages as well as POST requests such as user login, module storing, event > pages as well as POST requests such as user login, module storing, event
> invocation and also admin commands. > invocation and also admin commands.
*/ */
(function() { (function() {
var crypto, db, dirHandlers, exports, fs, getHandlerPath, getRemoteScripts, getScript, getTemplate, mustache, path, qs, renderPage, var crypto, db, dirHandlers, exports, fs, getHandlerPath, getRemoteScripts, getScript, getTemplate, mustache, path, qs, renderPage;
_this = this;
db = require('./persistence'); db = require('./persistence');
@ -28,29 +27,32 @@ Request Handler
dirHandlers = path.resolve(__dirname, '..', 'webpages', 'handlers'); dirHandlers = path.resolve(__dirname, '..', 'webpages', 'handlers');
exports = module.exports = function(args) { exports = module.exports = (function(_this) {
var user, users, _i, _len; return function(args) {
_this.log = args.logger; var user, users, _i, _len;
_this.userRequestHandler = args['request-service']; _this.log = args.logger;
_this.objAdminCmds = { _this.userRequestHandler = args['request-service'];
shutdown: function(obj, cb) { _this.objAdminCmds = {
var data; shutdown: function(obj, cb) {
data = { var data;
code: 200, data = {
message: 'Shutting down... BYE!' code: 200,
}; message: 'Shutting down... BYE!'
setTimeout(args['shutdown-function'], 500); };
return cb(null, data); setTimeout(args['shutdown-function'], 500);
return cb(null, data);
}
};
db(args);
users = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'config', 'users.json')));
for (_i = 0, _len = users.length; _i < _len; _i++) {
user = users[_i];
db.storeUser(user);
} }
return module.exports;
}; };
db(args); })(this);
users = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'config', 'users.json')));
for (_i = 0, _len = users.length; _i < _len; _i++) {
user = users[_i];
db.storeUser(user);
}
return module.exports;
};
/* /*
Handles possible events that were posted to this server and pushes them into the Handles possible events that were posted to this server and pushes them into the
@ -62,8 +64,7 @@ Request Handler
objects.* objects.*
@public handleEvent( *req, resp* ) @public handleEvent( *req, resp* )
*/ */
exports.handleEvent = function(req, resp) { exports.handleEvent = function(req, resp) {
var body; var body;
@ -94,6 +95,7 @@ Request Handler
}); });
}; };
/* /*
Associates the user object with the session if login is successful. Associates the user object with the session if login is successful.
@ -103,32 +105,34 @@ Request Handler
objects.* objects.*
@public handleLogin( *req, resp* ) @public handleLogin( *req, resp* )
*/ */
exports.handleLogin = (function(_this) {
exports.handleLogin = function(req, resp) { return function(req, resp) {
var body; var body;
body = ''; body = '';
req.on('data', function(data) { req.on('data', function(data) {
return body += data; return body += data;
});
return req.on('end', function() {
var obj;
obj = qs.parse(body);
return db.loginUser(obj.username, obj.password, function(err, usr) {
if (err) {
_this.log.warn("RH | AUTH-UH-OH ( " + obj.username + " ): " + err.message);
} else {
req.session.user = usr;
}
if (req.session.user) {
return resp.send('OK!');
} else {
return resp.send(401, 'NO!');
}
}); });
}); return req.on('end', function() {
}; var obj;
obj = qs.parse(body);
return db.loginUser(obj.username, obj.password, function(err, usr) {
if (err) {
_this.log.warn("RH | AUTH-UH-OH ( " + obj.username + " ): " + err.message);
} else {
req.session.user = usr;
}
if (req.session.user) {
return resp.send('OK!');
} else {
return resp.send(401, 'NO!');
}
});
});
};
})(this);
/* /*
A post request retrieved on this handler causes the user object to be A post request retrieved on this handler causes the user object to be
@ -140,8 +144,7 @@ Request Handler
objects.* objects.*
@public handleLogout( *req, resp* ) @public handleLogout( *req, resp* )
*/ */
exports.handleLogout = function(req, resp) { exports.handleLogout = function(req, resp) {
if (req.session) { if (req.session) {
@ -150,25 +153,25 @@ Request Handler
} }
}; };
/* /*
Resolves the path to a handler webpage. Resolves the path to a handler webpage.
@private getHandlerPath( *name* ) @private getHandlerPath( *name* )
@param {String} name @param {String} name
*/ */
getHandlerPath = function(name) { getHandlerPath = function(name) {
return path.join(dirHandlers, name + '.html'); return path.join(dirHandlers, name + '.html');
}; };
/* /*
Fetches a template. Fetches a template.
@private getTemplate( *name* ) @private getTemplate( *name* )
@param {String} name @param {String} name
*/ */
getTemplate = function(name) { getTemplate = function(name) {
var pth; var pth;
@ -176,13 +179,13 @@ Request Handler
return fs.readFileSync(pth, 'utf8'); return fs.readFileSync(pth, 'utf8');
}; };
/* /*
Fetches a script. Fetches a script.
@private getScript( *name* ) @private getScript( *name* )
@param {String} name @param {String} name
*/ */
getScript = function(name) { getScript = function(name) {
var pth; var pth;
@ -190,13 +193,13 @@ Request Handler
return fs.readFileSync(pth, 'utf8'); return fs.readFileSync(pth, 'utf8');
}; };
/* /*
Fetches remote scripts snippets. Fetches remote scripts snippets.
@private getRemoteScripts( *name* ) @private getRemoteScripts( *name* )
@param {String} name @param {String} name
*/ */
getRemoteScripts = function(name) { getRemoteScripts = function(name) {
var pth; var pth;
@ -204,6 +207,7 @@ Request Handler
return fs.readFileSync(pth, 'utf8'); return fs.readFileSync(pth, 'utf8');
}; };
/* /*
Renders a page, with helps of mustache, depending on the user session and returns it. Renders a page, with helps of mustache, depending on the user session and returns it.
@ -211,8 +215,7 @@ Request Handler
@param {String} name @param {String} name
@param {Object} sess @param {Object} sess
@param {Object} msg @param {Object} msg
*/ */
renderPage = function(name, req, resp, msg) { renderPage = function(name, req, resp, msg) {
var code, content, data, err, menubar, page, pageElements, pathSkel, remote_scripts, script, skeleton; var code, content, data, err, menubar, page, pageElements, pathSkel, remote_scripts, script, skeleton;
@ -251,6 +254,7 @@ Request Handler
return resp.send(code, mustache.render(page, data)); return resp.send(code, mustache.render(page, data));
}; };
/* /*
Present the desired forge page to the user. Present the desired forge page to the user.
@ -260,8 +264,7 @@ Request Handler
objects.* objects.*
@public handleForge( *req, resp* ) @public handleForge( *req, resp* )
*/ */
exports.handleForge = function(req, resp) { exports.handleForge = function(req, resp) {
var page; var page;
@ -272,6 +275,7 @@ Request Handler
return renderPage(page, req, resp); return renderPage(page, req, resp);
}; };
/* /*
Handles the user command requests. Handles the user command requests.
@ -281,27 +285,29 @@ Request Handler
objects.* objects.*
@public handleUser( *req, resp* ) @public handleUser( *req, resp* )
*/ */
exports.handleUserCommand = (function(_this) {
exports.handleUserCommand = function(req, resp) { return function(req, resp) {
var body; var body;
if (req.session && req.session.user) { if (req.session && req.session.user) {
body = ''; body = '';
req.on('data', function(data) { req.on('data', function(data) {
return body += data; return body += data;
});
return req.on('end', function() {
var obj;
obj = qs.parse(body);
return _this.userRequestHandler(req.session.user, obj, function(obj) {
return resp.send(obj.code, obj);
}); });
}); return req.on('end', function() {
} else { var obj;
return resp.send(401, 'Login first!'); obj = qs.parse(body);
} return _this.userRequestHandler(req.session.user, obj, function(obj) {
}; return resp.send(obj.code, obj);
});
});
} else {
return resp.send(401, 'Login first!');
}
};
})(this);
/* /*
Present the admin console to the user if he's allowed to see it. Present the admin console to the user if he's allowed to see it.
@ -312,8 +318,7 @@ Request Handler
objects.* objects.*
@public handleForge( *req, resp* ) @public handleForge( *req, resp* )
*/ */
exports.handleAdmin = function(req, resp) { exports.handleAdmin = function(req, resp) {
var msg, page; var msg, page;
@ -328,6 +333,7 @@ Request Handler
return renderPage(page, req, resp, msg); return renderPage(page, req, resp, msg);
}; };
/* /*
Handles the admin command requests. Handles the admin command requests.
@ -337,31 +343,32 @@ Request Handler
objects.* objects.*
@public handleAdminCommand( *req, resp* ) @public handleAdminCommand( *req, resp* )
*/ */
exports.handleAdminCommand = (function(_this) {
exports.handleAdminCommand = function(req, resp) { return function(req, resp) {
var body; var body;
if (req.session && req.session.user && req.session.user.isAdmin === "true") { if (req.session && req.session.user && req.session.user.isAdmin === "true") {
body = ''; body = '';
req.on('data', function(data) { req.on('data', function(data) {
return body += data; return body += data;
}); });
return req.on('end', function() { return req.on('end', function() {
var obj; var obj;
obj = qs.parse(body); obj = qs.parse(body);
_this.log.info('RH | Received admin request: ' + obj.command); _this.log.info('RH | Received admin request: ' + obj.command);
if (obj.command && _this.objAdminCmds[obj.command]) { if (obj.command && _this.objAdminCmds[obj.command]) {
return _this.objAdminCmds[obj.command](obj, function(err, obj) { return _this.objAdminCmds[obj.command](obj, function(err, obj) {
return resp.send(obj.code, obj); return resp.send(obj.code, obj);
}); });
} else { } else {
return resp.send(404, 'Command unknown!'); return resp.send(404, 'Command unknown!');
} }
}); });
} else { } else {
return resp.send(401, 'You need to be logged in as admin!'); return resp.send(401, 'You need to be logged in as admin!');
} }
}; };
})(this);
}).call(this); }).call(this);

View file

@ -1,4 +1,5 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
/* /*
WebAPI-ECA Engine WebAPI-ECA Engine
@ -9,12 +10,10 @@ WebAPI-ECA Engine
> node webapi-eca [opt] > node webapi-eca [opt]
> >
> See below in the optimist CLI preparation for allowed optional parameters `[opt]`. > See below in the optimist CLI preparation for allowed optional parameters `[opt]`.
*/ */
(function() { (function() {
var argv, cm, conf, cp, db, engine, fs, http, init, logger, nameEP, opt, optimist, path, procCmds, shutDown, usage, var argv, cm, conf, cp, db, engine, fs, http, init, logger, nameEP, opt, optimist, path, procCmds, shutDown, usage;
_this = this;
logger = require('./logging'); logger = require('./logging');
@ -40,10 +39,10 @@ WebAPI-ECA Engine
procCmds = {}; procCmds = {};
/* /*
Let's prepare the optimist CLI optional arguments `[opt]`: Let's prepare the optimist CLI optional arguments `[opt]`:
*/ */
usage = 'This runs your webapi-based ECA engine'; usage = 'This runs your webapi-based ECA engine';
@ -93,113 +92,117 @@ WebAPI-ECA Engine
process.exit(); process.exit();
} }
/* /*
This function is invoked right after the module is loaded and starts the server. This function is invoked right after the module is loaded and starts the server.
@private init() @private init()
*/ */
init = (function(_this) {
init = function() { return function() {
var args, logconf; var args, logconf;
conf(argv.c); conf(argv.c);
if (!conf.isReady()) { if (!conf.isReady()) {
console.error('FAIL: Config file not ready! Shutting down...'); console.error('FAIL: Config file not ready! Shutting down...');
process.exit(); process.exit();
}
logconf = conf.getLogConf();
if (argv.m) {
logconf['mode'] = argv.m;
}
if (argv.i) {
logconf['io-level'] = argv.i;
}
if (argv.f) {
logconf['file-level'] = argv.f;
}
if (argv.p) {
logconf['file-path'] = argv.p;
}
if (argv.n) {
logconf['nolog'] = argv.n;
}
try {
fs.unlinkSync(path.resolve(__dirname, '..', 'logs', logconf['file-path']));
} catch (_error) {}
_this.log = logger.getLogger(logconf);
_this.log.info('RS | STARTING SERVER');
args = {
logger: _this.log,
logconf: logconf
};
args['http-port'] = parseInt(argv.w || conf.getHttpPort());
args['db-port'] = parseInt(argv.d || conf.getDbPort());
_this.log.info('RS | Initialzing DB');
db(args);
return db.isConnected(function(err) {
var cliArgs, poller;
if (err) {
_this.log.error('RS | No DB connection, shutting down system!');
return shutDown();
} else {
_this.log.info('RS | Initialzing engine');
engine(args);
_this.log.info('RS | Forking a child process for the event poller');
cliArgs = [args.logconf['mode'], args.logconf['io-level'], args.logconf['file-level'], args.logconf['file-path'], args.logconf['nolog']];
poller = cp.fork(path.resolve(__dirname, nameEP), cliArgs);
_this.log.info('RS | Initialzing module manager');
cm(args);
cm.addListener('init', function(evt) {
return poller.send({
event: 'init',
data: evt
});
});
cm.addListener('newRule', function(evt) {
return poller.send({
event: 'newRule',
data: evt
});
});
cm.addListener('init', function(evt) {
return engine.internalEvent('init', evt);
});
cm.addListener('newRule', function(evt) {
return engine.internalEvent('newRule', evt);
});
_this.log.info('RS | Initialzing http listener');
args['request-service'] = cm.processRequest;
args['shutdown-function'] = shutDown;
return http(args);
} }
}); logconf = conf.getLogConf();
}; if (argv.m) {
logconf['mode'] = argv.m;
}
if (argv.i) {
logconf['io-level'] = argv.i;
}
if (argv.f) {
logconf['file-level'] = argv.f;
}
if (argv.p) {
logconf['file-path'] = argv.p;
}
if (argv.n) {
logconf['nolog'] = argv.n;
}
try {
fs.unlinkSync(path.resolve(__dirname, '..', 'logs', logconf['file-path']));
} catch (_error) {}
_this.log = logger.getLogger(logconf);
_this.log.info('RS | STARTING SERVER');
args = {
logger: _this.log,
logconf: logconf
};
args['http-port'] = parseInt(argv.w || conf.getHttpPort());
args['db-port'] = parseInt(argv.d || conf.getDbPort());
_this.log.info('RS | Initialzing DB');
db(args);
return db.isConnected(function(err) {
var cliArgs, poller;
if (err) {
_this.log.error('RS | No DB connection, shutting down system!');
return shutDown();
} else {
_this.log.info('RS | Initialzing engine');
engine(args);
_this.log.info('RS | Forking a child process for the event poller');
cliArgs = [args.logconf['mode'], args.logconf['io-level'], args.logconf['file-level'], args.logconf['file-path'], args.logconf['nolog']];
poller = cp.fork(path.resolve(__dirname, nameEP), cliArgs);
_this.log.info('RS | Initialzing module manager');
cm(args);
cm.addListener('init', function(evt) {
return poller.send({
event: 'init',
data: evt
});
});
cm.addListener('newRule', function(evt) {
return poller.send({
event: 'newRule',
data: evt
});
});
cm.addListener('init', function(evt) {
return engine.internalEvent('init', evt);
});
cm.addListener('newRule', function(evt) {
return engine.internalEvent('newRule', evt);
});
_this.log.info('RS | Initialzing http listener');
args['request-service'] = cm.processRequest;
args['shutdown-function'] = shutDown;
return http(args);
}
});
};
})(this);
/* /*
Shuts down the server. Shuts down the server.
@private shutDown() @private shutDown()
*/ */
shutDown = (function(_this) {
return function() {
_this.log.warn('RS | Received shut down command!');
if (db != null) {
db.shutDown();
}
if (engine != null) {
engine.shutDown();
}
return process.exit();
};
})(this);
shutDown = function() {
_this.log.warn('RS | Received shut down command!');
if (db != null) {
db.shutDown();
}
if (engine != null) {
engine.shutDown();
}
return process.exit();
};
/* /*
## Process Commands *# Process Commands
When the server is run as a child process, this function handles messages When the server is run as a child process, this function handles messages
from the parent process (e.g. the testing suite) from the parent process (e.g. the testing suite)
*/ */
process.on('message', function(cmd) { process.on('message', function(cmd) {
return typeof procCmds[cmd] === "function" ? procCmds[cmd]() : void 0; return typeof procCmds[cmd] === "function" ? procCmds[cmd]() : void 0;

View file

@ -19,7 +19,7 @@ exports.testParameters = ( test ) =>
'mode' 'mode'
'io-level' 'io-level'
'file-level' 'file-level'
'file-path' # 'file-path'
] ]
test.expect 3 + reqProp.length test.expect 3 + reqProp.length
test.ok @conf.getHttpPort(), 'HTTP port does not exist!' test.ok @conf.getHttpPort(), 'HTTP port does not exist!'

View file

@ -3,7 +3,7 @@ exports.setUp = ( cb ) =>
@path = require 'path' @path = require 'path'
logger = require @path.join '..', 'js-coffee', 'logging' logger = require @path.join '..', 'js-coffee', 'logging'
@log = logger.getLogger @log = logger.getLogger
nolog: true nolog: true
@db = require @path.join '..', 'js-coffee', 'persistence' @db = require @path.join '..', 'js-coffee', 'persistence'
opts = opts =
logger: @log logger: @log
@ -140,6 +140,7 @@ exports.EventQueue =
### ###
exports.ActionInvoker = exports.ActionInvoker =
setUp: ( cb ) => setUp: ( cb ) =>
@userId = 'tester1'
@action1id = 'test-action-invoker_1' @action1id = 'test-action-invoker_1'
@action2id = 'test-action-invoker_2' @action2id = 'test-action-invoker_2'
@action1 = @action1 =
@ -158,7 +159,7 @@ exports.ActionInvoker =
testCreateAndRead: ( test ) => testCreateAndRead: ( test ) =>
test.expect 3 test.expect 3
# store an entry to start with # store an entry to start with
@db.storeActionInvoker @action1id, @action1 @db.storeActionInvoker @action1id, @userId, @action1
# test that the ID shows up in the set # test that the ID shows up in the set
@db.getActionInvokerIds ( err , obj ) => @db.getActionInvokerIds ( err , obj ) =>
@ -180,8 +181,8 @@ exports.ActionInvoker =
test.expect 2 test.expect 2
# store an entry to start with # store an entry to start with
@db.storeActionInvoker @action1id, @action1 @db.storeActionInvoker @action1id, @userId, @action1
@db.storeActionInvoker @action1id, @action2 @db.storeActionInvoker @action1id, @userId, @action2
# the retrieved object really is the one we expected # the retrieved object really is the one we expected
@db.getActionInvoker @action1id, ( err , obj ) => @db.getActionInvoker @action1id, ( err , obj ) =>
@ -198,7 +199,7 @@ exports.ActionInvoker =
test.expect 2 test.expect 2
# store an entry to start with # store an entry to start with
@db.storeActionInvoker @action1id, @action1 @db.storeActionInvoker @action1id, @userId, @action1
# Ensure the action invoker has been deleted # Ensure the action invoker has been deleted
@db.deleteActionInvoker @action1id @db.deleteActionInvoker @action1id
@ -227,8 +228,8 @@ exports.ActionInvoker =
"Invoker #{ modname } does not equal the expected one" "Invoker #{ modname } does not equal the expected one"
forkEnds() forkEnds()
@db.storeActionInvoker @action1id, @action1 @db.storeActionInvoker @action1id, @userId, @action1
@db.storeActionInvoker @action2id, @action2 @db.storeActionInvoker @action2id, @userId, @action2
@db.getActionInvokerIds ( err, obj ) => @db.getActionInvokerIds ( err, obj ) =>
test.ok @action1id in obj and @action2id in obj, test.ok @action1id in obj and @action2id in obj,
'Not all action invoker Ids in set' 'Not all action invoker Ids in set'
@ -309,6 +310,7 @@ exports.ActionInvokerParams =
### ###
exports.EventPoller = exports.EventPoller =
setUp: ( cb ) => setUp: ( cb ) =>
@userId = 'tester1'
@event1id = 'test-event-poller_1' @event1id = 'test-event-poller_1'
@event2id = 'test-event-poller_2' @event2id = 'test-event-poller_2'
@event1 = @event1 =
@ -327,7 +329,7 @@ exports.EventPoller =
testCreateAndRead: ( test ) => testCreateAndRead: ( test ) =>
test.expect 3 test.expect 3
# store an entry to start with # store an entry to start with
@db.storeEventPoller @event1id, @event1 @db.storeEventPoller @event1id, @userId, @event1
# test that the ID shows up in the set # test that the ID shows up in the set
@db.getEventPollerIds ( err , obj ) => @db.getEventPollerIds ( err , obj ) =>
@ -349,8 +351,8 @@ exports.EventPoller =
test.expect 2 test.expect 2
# store an entry to start with # store an entry to start with
@db.storeEventPoller @event1id, @event1 @db.storeEventPoller @event1id, @userId, @event1
@db.storeEventPoller @event1id, @event2 @db.storeEventPoller @event1id, @userId, @event2
# the retrieved object really is the one we expected # the retrieved object really is the one we expected
@db.getEventPoller @event1id, ( err , obj ) => @db.getEventPoller @event1id, ( err , obj ) =>
@ -367,7 +369,7 @@ exports.EventPoller =
test.expect 2 test.expect 2
# store an entry to start with # store an entry to start with
@db.storeEventPoller @event1id, @event1 @db.storeEventPoller @event1id, @userId, @event1
# Ensure the event poller has been deleted # Ensure the event poller has been deleted
@db.deleteEventPoller @event1id @db.deleteEventPoller @event1id
@ -396,8 +398,8 @@ exports.EventPoller =
"Invoker #{ modname } does not equal the expected one" "Invoker #{ modname } does not equal the expected one"
forkEnds() forkEnds()
@db.storeEventPoller @event1id, @event1 @db.storeEventPoller @event1id, @userId, @event1
@db.storeEventPoller @event2id, @event2 @db.storeEventPoller @event2id, @userId, @event2
@db.getEventPollerIds ( err, obj ) => @db.getEventPollerIds ( err, obj ) =>
test.ok @event1id in obj and @event2id in obj, test.ok @event1id in obj and @event2id in obj,
'Not all event poller Ids in set' 'Not all event poller Ids in set'

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.7.1
(function() { (function() {
var fOnLoad; var fOnLoad;