Skip to content

Commit

Permalink
Merge pull request #1 from fs-opensource/master
Browse files Browse the repository at this point in the history
Use server.stop() method directly
  • Loading branch information
roylines committed Apr 7, 2016
2 parents e6f0fbd + 28c473d commit 46848e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exports.register = function(server, options, done) {
process.on('message', function(msg) {
if (msg === 'shutdown') {
server.log(['info', 'pm2', 'shutdown'], 'stopping hapi...');
server.root.stop(options, function() {
server.stop(options, function() {
server.log(['info', 'pm2', 'shutdown'], 'hapi stopped');
return process.exit(0);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hapi-graceful-pm2",
"version": "1.0.0",
"version": "1.0.13",
"description": "hapi plugin to handle graceful pm2 reloads",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ lab.experiment("hapi-graceful-pm2", () => {
lab.beforeEach((done) => {
sinon.stub(process, 'on').returns();
sinon.stub(process, 'exit');
server.root = {};
server.root.stop = sinon.stub();
server.stop = sinon.stub();
server.log = sinon.stub();

return plugin.register(server, options, done);
Expand All @@ -41,11 +40,11 @@ lab.experiment("hapi-graceful-pm2", () => {

lab.test("should stop server if shutdown", (done) => {
server.log.returns();
server.root.stop.yields();
server.stop.yields();
process.exit.restore();
sinon.stub(process, 'exit', function(code) {
code.should.equal(0);
server.root.stop.calledOnce.should.be.true;
server.stop.calledOnce.should.be.true;
return done();
});

Expand Down

0 comments on commit 46848e2

Please sign in to comment.