Skip to content

Commit

Permalink
add initial heap dump endpoint if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Mar 28, 2017
1 parent 4e7d5e7 commit e7734ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ static/bower_components/
coverage/

npm-debug.log
*.heapsnapshot
12 changes: 12 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ function create (env, ctx) {
res.sendFile(__dirname + '/swagger.yaml');
});

if (env.settings.isEnabled('dumps')) {
var heapdump = require('heapdump');
app.get('/api/v2/dumps/start', function (req, res) {
var path = new Date().toISOString() + '.heapsnapshot';
path = _.replace(path, ':', '-');
console.info('writing dump to', path);
heapdump.writeSnapshot(path);
res.send('wrote dump to ' + path);
});
}


//app.get('/package.json', software);

// define static server
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"express-extension-to-accept": "0.0.2",
"forever": "~0.15.2",
"git-rev": "git://github.com/bewest/git-rev.git",
"heapdump": "^0.3.7",
"jquery": "^2.1.4",
"jsonwebtoken": "^7.1.9",
"lodash": "^4.16.4",
Expand Down

0 comments on commit e7734ad

Please sign in to comment.