Browse Source

Initial commit to make this install smaller.

main
Zed A. Shaw 11 months ago
parent
commit
62c75cd29d
  1. 18
      ecosystem.config.js
  2. 56
      tracker.js

18
ecosystem.config.js

@ -0,0 +1,18 @@
module.exports = {
apps : [
{
name: 'tracker',
script: './scripts/services/tracker.js',
instances: 1,
autorestart: true,
watch: ["lib", "scripts/services"],
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
},
],
};

56
tracker.js

@ -0,0 +1,56 @@
const Server = require('bittorrent-tracker').Server
const port = 9001;
const hostname = '0.0.0.0';
const server = new Server({
udp: false, // enable udp server? [default=true]
http: true, // enable http server? [default=true]
ws: true, // enable websocket server? [default=true]
stats: true, // enable web-based statistics? [default=true]
filter: function (infoHash, params, cb) {
console.log("----------------------------------------------");
console.debug(params);
cb(null)
}
})
server.on('error', function (err) {
// fatal server error!
console.log(err.message)
})
server.on('warning', function (err) {
// client sent bad data. probably not a problem, just a buggy client.
console.log(err.message)
})
server.on('listening', function () {
// fired when all requested servers are listening
console.log('listening on port:' + server.http.address().port)
})
// start tracker server listening! Use 0 to listen on a random free port.
server.listen(port, hostname, function (what) {
console.log("Listening....");
})
// listen for individual tracker messages from peers:
server.on('start', function (addr) {
console.log('got start message from ' + addr)
})
server.on('complete', function (addr) {
console.log('complete', addr);
});
server.on('update', function (addr) {
console.log('update', addr);
});
server.on('stop', function (addr) {
console.log('stop', addr);
});
const onHttpReq = server.onHttpRequest.bind(server);
Loading…
Cancel
Save