Skip to content

Commit

Permalink
basic tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed May 19, 2012
1 parent 03b2174 commit b2f677d
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 428 deletions.
4 changes: 4 additions & 0 deletions api.js
Expand Up @@ -86,6 +86,10 @@ var createActionHero = function(){

// determine my unique ID
var externalIP = api.utils.getExternalIPAddress();
if(externalIP == false){
console.log("Error fetching this host's external IP address; setting to random string")
externalIP = api.utils.randomString(128);
}
api.id = externalIP + ":" + api.configData.webServerPort + "&" + api.configData.socketServerPort;

var successMessage = "*** Server Started @ " + api.utils.sqlDateTime() + " @ web port " + api.configData.webServerPort;
Expand Down
14 changes: 1 addition & 13 deletions config.json
@@ -1,5 +1,5 @@
{
"apiVersion" : "1.0.3",
"apiVersion" : "2.0.0",
"webServerPort" : 8080,
"socketServerPort" : 5000,
"serverName" : "actionHero API",
Expand All @@ -26,18 +26,6 @@
"maxLogFileSize" : 10485760,
"logTable" : "log",
"logRequests" : true,

"actionCluster": {
"Key" : "4ijhaijhm43yjnawhja43jaj",
"ReConnectToLostPeersMS" : 5000,
"CycleCheckTimeMS" : 10,
"remoteTimeoutWaitMS" : 5000,
"nodeDuplication" : 2,
"StartingPeer" : {
"host": null,
"port": null
}
},

"redis" : {
"enable": true,
Expand Down
8 changes: 5 additions & 3 deletions initializers/initCache.js
Expand Up @@ -50,7 +50,7 @@ var initCache = function(api, next){
if(api.redis.enable === true){
api.redis.client.hget(redisCacheKey, key, function (err, cacheObj){
cacheObj = JSON.parse(cacheObj);
if(cacheObj.expireTimestamp >= (new Date().getTime())){
if(cacheObj != null && cacheObj.expireTimestamp >= (new Date().getTime())){
cacheObj.readAt = new Date().getTime();
api.redis.client.hset(redisCacheKey, key, JSON.stringify(cacheObj), function(){
if(typeof next == "function"){
Expand Down Expand Up @@ -84,8 +84,10 @@ var initCache = function(api, next){

api.cache.destroy = function(api, key, next){
if(api.redis.enable === true){
api.redis.client.hdel(redisCacheKey, key, function(){
if(typeof next == "function"){ process.nextTick(function() { next(true); }); }
api.redis.client.hdel(redisCacheKey, key, function(err, count){
var resp = true;
if(count != 1){ resp = false; }
if(typeof next == "function"){ process.nextTick(function() { next(resp); }); }
});
}else{
var cacheObj = api.cache.data[key];
Expand Down
1 change: 1 addition & 0 deletions initializers/initStats.js
Expand Up @@ -38,6 +38,7 @@ var initStats = function(api, next){
api.stats.load = function(api, next){
var stats = {};
var now = new Date().getTime();
stats.id = api.id;
stats.uptimeSeconds = (now - api.bootTime) / 1000;
api.cache.size(api, function(numberOfCacheObjects){
api.stats.get(api, "numberOfSocketRequests", function(numberOfSocketRequests){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Evan Tahler <evantahler@gmail.com>",
"name": "actionHero",
"description": "actionHero is a minimalist, multi-node, transactional API framework written in javaScript",
"version": "3.0.0",
"version": "2.0.0",
"homepage": "https://github.com/evantahler/actionHero",
"repository": {
"type": "git",
Expand Down
7 changes: 3 additions & 4 deletions spec/action_status.js
Expand Up @@ -19,11 +19,10 @@ suite.addBatch({
"status: stats": {
topic: function(){ specHelper.apiTest.get(actionUrl, 0, {} ,this.callback ); },
stats: function(res, b){
specHelper.assert.isTrue(res.body.stats.webServer.numberOfWebRequests > 0);
specHelper.assert.isTrue(res.body.stats.socketServer.numberOfSocketRequests >= 0);
specHelper.assert.isTrue(res.body.stats.startTime > 0);
specHelper.assert.isTrue(res.body.stats.webServer.numberOfGlobalWebRequests > 0);
specHelper.assert.isTrue(res.body.stats.socketServer.numberOfGlobalSocketRequests >= 0);
specHelper.assert.isTrue(res.body.stats.uptimeSeconds > 0);
specHelper.assert.isTrue(res.body.stats.pid > 0);
specHelper.assert.isTrue(res.body.stats.id.length > 0);
},
},

Expand Down

0 comments on commit b2f677d

Please sign in to comment.