Skip to content

Commit

Permalink
Log load. Closes #1573
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed May 24, 2014
1 parent 8b2d30d commit 3c04cd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ internals.Server.prototype._dispatch = function (options) {
(limits.maxHeapUsedBytes && load.heapUsed > limits.maxHeapUsedBytes) ||
(limits.maxRssBytes && load.rss > limits.maxRssBytes))) {

self.log(['hapi', 'load'], load);
request._reply(Boom.serverTimeout('Server under heavy load', load));
}
else {
Expand Down
13 changes: 9 additions & 4 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ describe('Server', function () {
reply('ok');
};

var logged = null;
server.once('log', function (event, tags) {

logged = (tags.hapi && tags.load && event.data);
});

server.route({ method: 'GET', path: '/', handler: handler });
server.start(function (err) {

Expand All @@ -322,10 +328,9 @@ describe('Server', function () {
server.inject('/', function (res) {

expect(res.statusCode).to.equal(503);
server.stop(function () {

done();
});
expect(logged.rss > 10000).to.equal(true);
server.stop();
done();
});
});
});
Expand Down

0 comments on commit 3c04cd4

Please sign in to comment.