Comparing version 0.0.19 to 0.0.20
@@ -40,3 +40,3 @@ /* | ||
var enableUpdate = function(interval, all, cb){ | ||
interval = interval || ctx.CONFIG_UPDATE_INTERVAL; | ||
interval = interval || ctx.updateInterval; | ||
if (updateInterval){ | ||
@@ -152,10 +152,17 @@ clearInterval(updateInterval); | ||
var ext = path.extname(confPath); | ||
var name = path.basename(confPath, ext); | ||
var data; | ||
if (ext === '.js') { | ||
logger.trace('load config from ' +confPath); | ||
_.extend(confFromFile, require(confPath)); | ||
data = require(confPath); | ||
} else if (ext === '.json') { | ||
logger.trace('load config from ' +confPath); | ||
var content = fs.readFileSync(confPath); | ||
_.extend(confFromFile, JSON.parse(content.toString())); | ||
data = JSON.parse(content.toString()); | ||
} | ||
if (name === 'idc'){ | ||
ctx.currentIDC = data.idc.toString(); | ||
}else{ | ||
_.extend(confFromFile, data); | ||
} | ||
} | ||
@@ -162,0 +169,0 @@ |
@@ -12,2 +12,2 @@ /* | ||
//default config update time is 300s | ||
module.exports.CONFIG_UPDATE_INTERVAL = 300000; | ||
module.exports.updateInterval = 300000; |
@@ -289,2 +289,3 @@ /* | ||
ctx.currentIDC = options.currentIDC; | ||
ctx.updateInterval = options.updateInterval; | ||
loggerGen.options = options.logger; | ||
@@ -291,0 +292,0 @@ options.extDir.map(RalModule.load); |
{ | ||
"name": "node-ral", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "a rpc client for node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var RalModule = require('../lib/ralmodule.js'); | ||
var ctx = require('../lib/ctx.js'); | ||
@@ -83,3 +84,4 @@ RalModule.load(__dirname + path.sep + '../lib/ext'); | ||
confs.should.containEql('bookService', 'bookServiceBNS', 'bookListService', 'bookListServiceWithCUI'); | ||
ctx.currentIDC.should.be.equal('tc'); | ||
}); | ||
}); |
253484
60
6885