well lets give this a try

This commit is contained in:
reality 2013-11-02 21:40:10 +00:00
parent fc415aa6c6
commit 2ce0e67d4b
2 changed files with 16 additions and 13 deletions

View File

@ -15,19 +15,23 @@ var DatabaseDriver = function(config) {
* Connect to or create a new DataBank
*/
DatabaseDriver.prototype.createDB = function(name, driver, schema, callback) {
var params = { 'schema': schema };
if(!_.has(this.databanks, name)) {
var params = { 'schema': schema };
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
if(driver == 'disk') params.dir = 'db';
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
if(driver == 'disk') params.dir = 'db';
this.databanks[name] = Databank.get(driver, params);
this.databanks[name].connect({}, function(err) {
if(err) {
console.log('Didn\'t manage to connect to the data source - ' + err);
} else {
callback(this.databanks[name]);
}
}.bind(this));
this.databanks[name] = Databank.get(driver, params);
this.databanks[name].connect({}, function(err) {
if(err) {
console.log('Didn\'t manage to connect to the data source - ' + err);
} else {
callback(this.databanks[name]);
}
}.bind(this));
} else {
callback(this.databanks[name]);
}
};
exports.DatabaseDriver = DatabaseDriver;

3
run.js
View File

@ -165,6 +165,7 @@ DBot.prototype.reloadModules = function() {
delete require.cache[path];
require('./snippets');
// Clear JSBot listeners and hooks
this.instance.removeListeners();
this.instance.clearHooks();
@ -217,7 +218,6 @@ DBot.prototype.reloadModules = function() {
}
}
process.nextTick(function() {
_.each(moduleNames, function(name) {
if(this.status[name] === true) {
try {
@ -304,7 +304,6 @@ DBot.prototype.reloadModules = function() {
this.modules[module.name] = module;
}
}.bind(this));
}.bind(this));
process.nextTick(function() {
if(_.has(this.modules, 'web')) this.modules.web.reloadPages();