source: trip-planner-front/node_modules/killable/README.md@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1killable
2========
3
4Keeps track of a server's open sockets so they can be destroyed at a
5moment's notice. This way, the server connection can be killed very
6fast.
7
8Installation
9------------
10
11```
12npm install killable
13```
14
15Example usage
16-------------
17
18Using express:
19('server' in the example is just an ``http.server``, so other frameworks
20or pure Node should work just as well.)
21
22```javascript
23var killable = require('killable');
24
25var app = require('express')();
26var server;
27
28app.route('/', function (req, res, next) {
29 res.send('Server is going down NOW!');
30
31 server.kill(function () {
32 //the server is down when this is called. That won't take long.
33 });
34});
35
36var server = app.listen(8080);
37killable(server);
38```
39
40API
41---
42
43The ``killable`` module is callable. When you call it on a Node
44``http.Server`` object, it will add a ``server.kill()`` method on it. It
45returns the server object.
46
47``server.kill([callback])`` closes all open sockets and calls
48``server.close()``, to which the ``callback`` is passed on.
49
50Inspired by: http://stackoverflow.com/a/14636625
51
52License
53-------
54
55ISC
Note: See TracBrowser for help on using the repository browser.