Skip to content

Commit

Permalink
support config reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
bevacqua committed Mar 31, 2016
1 parent 5fb703b commit 4342ed5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
27 changes: 21 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,32 @@ var internals = {};


exports.register = function (server, options, next) {
var monitor;

var monitor = new Monitor(server, options);
server.expose('monitor', monitor);
server.on('stop', function () {
server.on('stop', stopping);
reconfigure(options, next);

monitor.stop();
});
server.expose('monitor', monitor);

return monitor.start(next);
function reconfigure (options, next) {
if (monitor) {
monitor.stop();
monitor.reconfigure = noop;
}
monitor = new Monitor(server, options);
monitor.start(next || noop);
monitor.reconfigure = reconfigure;
}

function stopping () {
if (monitor) {
monitor.stop();
}
}
};

function noop () {}

exports.register.attributes = {

pkg: require('../package.json')
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "good",
"name": "even-better",
"description": "Server and process monitoring plugin",
"version": "6.3.0",
"repository": "git://github.com/hapijs/good",
"version": "7.0.0",
"repository": "git://github.com/bevacqua/even-better",
"main": "lib/index.js",
"keywords": [
"process",
Expand Down

0 comments on commit 4342ed5

Please sign in to comment.