Keeps track of a server\textquotesingle{}s open sockets so they can be destroyed at a moment\textquotesingle{}s notice. This way, the server connection can be killed very fast.\hypertarget{md_sfcode_node_modules_killable_README_autotoc_md15770}{}\doxysection{Installation}\label{md_sfcode_node_modules_killable_README_autotoc_md15770}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install killable }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_killable_README_autotoc_md15771}{}\doxysection{Example usage}\label{md_sfcode_node_modules_killable_README_autotoc_md15771}
Using express\+: (\textquotesingle{}server\textquotesingle{} in the example is just an {\ttfamily http.\+server}, so other frameworks or pure Node should work just as well.)


\begin{DoxyCode}{0}
\DoxyCodeLine{var killable = require('killable');}
\DoxyCodeLine{}
\DoxyCodeLine{var app = require('express')();}
\DoxyCodeLine{var server;}
\DoxyCodeLine{}
\DoxyCodeLine{app.route('/', function (req, res, next) \{}
\DoxyCodeLine{  res.send('Server is going down NOW!');}
\DoxyCodeLine{}
\DoxyCodeLine{  server.kill(function () \{}
\DoxyCodeLine{    //the server is down when this is called. That won't take long.}
\DoxyCodeLine{  \});}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{var server = app.listen(8080);}
\DoxyCodeLine{killable(server); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_killable_README_autotoc_md15772}{}\doxysection{API}\label{md_sfcode_node_modules_killable_README_autotoc_md15772}
The {\ttfamily killable} module is callable. When you call it on a Node {\ttfamily http.\+Server} object, it will add a {\ttfamily server.\+kill()} method on it. It returns the server object.

{\ttfamily server.\+kill(\mbox{[}callback\mbox{]})} closes all open sockets and calls {\ttfamily server.\+close()}, to which the {\ttfamily callback} is passed on.

Inspired by\+: \href{http://stackoverflow.com/a/14636625}{\texttt{ http\+://stackoverflow.\+com/a/14636625}}\hypertarget{md_sfcode_node_modules_killable_README_autotoc_md15773}{}\doxysection{License}\label{md_sfcode_node_modules_killable_README_autotoc_md15773}
ISC 