Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

View File

@@ -0,0 +1,50 @@
killable
========
Keeps track of a server's open sockets so they can be destroyed at a
moment's notice. This way, the server connection can be killed very
fast.
Installation
------------
```
npm install killable
```
Example usage
-------------
Using express:
('server' in the example is just an ``http.server``, so other frameworks
or pure Node should work just as well.)
```javascript
var killable = require('killable');
var app = require('express')();
var server;
app.route('/', function (req, res, next) {
res.send('Server is going down NOW!');
server.kill(function () {
//the server is down when this is called. That won't take long.
});
});
var server = app.listen(8080);
killable(server);
```
API
---
The ``killable`` module is callable. When you call it on a Node
``http.Server`` object, it will add a ``server.kill()`` method on it. It
returns the server object.
``server.kill([callback])`` closes all open sockets and calls
``server.close()``, to which the ``callback`` is passed on.
Inspired by: http://stackoverflow.com/a/14636625

View File

@@ -0,0 +1,24 @@
module.exports = function makeKillable(server) {
var sockets = [];
server.on('connection', function (socket) {
//add socket to list
sockets.push(socket);
socket.once('close', function () {
//remove socket from list
sockets.splice(sockets.indexOf(socket), 1);
});
});
server.kill = function (cb) {
server.close(cb);
sockets.forEach(function (socket) {
socket.destroy();
});
// reset so the server can be restarted
sockets = [];
};
return server;
};

View File

@@ -0,0 +1,58 @@
{
"_args": [
[
"killable@1.0.0",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "killable@1.0.0",
"_id": "killable@1.0.0",
"_inBundle": false,
"_integrity": "sha1-2ouEvUfeU5WHj5XWTQLyRJ/gXms=",
"_location": "/react-scripts/killable",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "killable@1.0.0",
"name": "killable",
"escapedName": "killable",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/react-scripts/webpack-dev-server"
],
"_resolved": "https://registry.npmjs.org/killable/-/killable-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Marten de Vries"
},
"bugs": {
"url": "https://github.com/marten-de-vries/killable/issues"
},
"description": "Keeps track of a server's open sockets so they can be destroyed at a moment's notice.",
"homepage": "https://github.com/marten-de-vries/killable#readme",
"keywords": [
"express",
"http",
"server",
"socket",
"kill",
"truncate",
"destroy",
"restart",
"shutdown",
"immeadiately"
],
"license": "ISC",
"main": "index.js",
"name": "killable",
"repository": {
"type": "git",
"url": "git+https://github.com/marten-de-vries/killable.git"
},
"version": "1.0.0"
}