Skip to content

Commit

Permalink
Merge pull request #287 from skrenek/master
Browse files Browse the repository at this point in the history
Enable heap dump by sending a USR2 kill signal.
  • Loading branch information
skrenek committed Jul 24, 2014
2 parents 8427958 + b54e39e commit 58e9b6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ __restProxy.js
*.swp
*.lock-wscript
*.wafpickle-7
**/*.gz
49 changes: 27 additions & 22 deletions lib/feather.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var simpleId = require("./simple-id"),
fs = require("fs"),
nodePath = require('path'),
Parser = require('./parser'),
Promise = require('./promise').Promise;
Promise = require('./promise').Promise,
heapdump = require('heapdump');

/**
* @namespace serves as the root namespace for the entire framework
Expand All @@ -45,7 +46,7 @@ var feather = module.exports = /** @lends feather */ {

/**
* Uses ns to get a config value at a path (or null if path not found)
*
*
*/
config: function(path) {
return feather.ns(path, feather.appOptions, true);
Expand All @@ -61,7 +62,7 @@ var feather = module.exports = /** @lends feather */ {
*/
mkdirpSync: util.mkdirpSync,

/**
/**
* Parse signed cookies the way connect does. Convenience pass-through method.
*/
parseSignedCookie: util.parseSignedCookie,
Expand All @@ -72,23 +73,23 @@ var feather = module.exports = /** @lends feather */ {
parseSignedSessionId: function(signedSessionId) {
return util.parseSignedCookie(cookie, feather.appOptions.connect.session.secret);
},

/**
* Flyweight empty Function
* @memberOf feather
*/
emptyFn: function() {},

/**
* Flyweight empty Object
*/
emptyObj: {},

/**
* Flyweight empty String
*/
emptyString: "",

/**
* Flyweight empty Array
*/
Expand All @@ -115,12 +116,12 @@ var feather = module.exports = /** @lends feather */ {
options.appRoot = options.appRoot || __dirname;
options.publicRoot = options.publicRoot || nodePath.join(options.appRoot, "public");
options.port = options.port || 8080;

//store a read-only copy of options in cache so that other modules
//can inspect original options reliably
var cacheToken = uuid();
cache.setItemReadOnly("feather-options", options, cacheToken);
//store an unprotected copy for convenience
//store an unprotected copy for convenience
feather.appOptions = options;

//add a getter that wraps feather.config for cases where we're passing options into modules that don't see feather object...
Expand Down Expand Up @@ -160,7 +161,7 @@ var feather = module.exports = /** @lends feather */ {
this.onceState("ready", function() {
process.on('SIGINT', feather.shutdown);
process.on('SIGTERM', feather.shutdown);
});
});
//go right to the "loading state" since that is exactly what we're doing at the time this instance is created
return this.states.loading;
}
Expand Down Expand Up @@ -199,7 +200,7 @@ var feather = module.exports = /** @lends feather */ {
}
cache.setItem("feather-logger", feather.logger);

//handle uncaught exceptions
//handle uncaught exceptions
process.on("uncaughtException", function(err) {
var message = err;
if (err.stack) {
Expand Down Expand Up @@ -317,12 +318,12 @@ var feather = module.exports = /** @lends feather */ {
}
}
}
});
});





},

/**
* Shuts down the server cleanly, but not before it is ready for requests.
*/
Expand Down Expand Up @@ -358,7 +359,7 @@ var feather = module.exports = /** @lends feather */ {
feather.logger.error({message:"feather server cannot shut down. feather.stateMachine is undefined", category:"feather.server", immediately:true});
}
}, // end shutdown.

/**
* This function is used to start the feather engine.
*/
Expand All @@ -367,13 +368,17 @@ var feather = module.exports = /** @lends feather */ {

if (options.heapdump) {
this.heapTimer = setInterval(function() {
require('heapdump').writeSnapshot('logs/' + new Date().toISOString().replace(/[:\.]/g, '-') + '.heapsnapshot');
heapdump.writeSnapshot('logs/' + new Date().toISOString().replace(/[:\.]/g, '-') + '.heapsnapshot');
}, parseInt(options.heapdump) * 1000);
}

feather.init(options, cb);
},

heapDump: function() {
heapdump.writeSnapshot('logs/' + new Date().toISOString().replace(/[:\.]/g, '-') + '.heapsnapshot');
},

/**
* @namespace Root namespace for data class definitions and services
* @name feather.data
Expand Down Expand Up @@ -421,15 +426,15 @@ var feather = module.exports = /** @lends feather */ {
* @namespace Root namespace for Finite State Machine class definitions and services
* @name feather.fsm
*/
fsm: {
fsm: {
/**
* Framework access to {@link FiniteStateMachine} class.
*/
*/
FiniteStateMachine: FSM
},
},

event: {
EventPublisher: EventPublisher,
EventPublisher: EventPublisher,
RedisEventPublisher: RedisEventPublisher
},

Expand Down

0 comments on commit 58e9b6b

Please sign in to comment.