gracefultools
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -11,2 +11,3 @@ const { info, warn } = require('winston'); | ||
let httpListener; | ||
let onClose; | ||
@@ -30,2 +31,3 @@ const handleClose = () => { | ||
httpListener.close(handleClose); | ||
if (typeof onClose === 'function') onClose(event); | ||
@@ -41,3 +43,3 @@ setTimeout(handleTimeout, processTimeout); | ||
const start = (app, options) => { | ||
const start = (app, options, handler) => { | ||
const { host, port: desiredPort, timeout } = options; | ||
@@ -48,2 +50,3 @@ const port = desiredPort || 3000; | ||
if (typeof timeout === 'number') processTimeout = timeout; | ||
onClose = handler; | ||
@@ -50,0 +53,0 @@ const sendEvents = (text) => { |
@@ -9,3 +9,3 @@ { | ||
"bugs": "https://github.com/good-hood-gmbh/gracefultools/issues", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -12,0 +12,0 @@ "express", |
@@ -22,3 +22,4 @@ Graceful tools | ||
// When you're ready to start your app | ||
gracefulStart(app, { host, port, timeout }); | ||
// onShutdown - invoked when shutdown started | ||
gracefulStart(app, { host, port, timeout }, onShutdown); | ||
``` |
5243
48
25