Novage / wt-tracker

High-performance WebTorrent tracker
Apache License 2.0
249 stars 86 forks source link

Installing from Scratch on Centos 7 #28

Closed mrcolak closed 7 months ago

mrcolak commented 4 years ago

There wasn't a clear guide of how to install and run this tracker from scratch. I thought it would be helpful for others.

Installing Nodejs

sudo yum install epel-release curl -sL https://rpm.nodesource.com/setup_12.x | bash - sudo yum install nodejs node -v

v12.17.0

Installing Git and cloning Repository

yum install git cd /usr/local git clone https://github.com/Novage/wt-tracker.git

Installing wt-tracker

cd wt-tracker/ npm install npm run build

#uWebSockets version v15.11.0 needed, so we are reinstalling uWebSockets npm uninstall uWebSockets.js npm install uNetworking/uWebSockets.js#v15.11.0

Creating config.json

vi /usr/local/wt-tracker/config.json

{
  "servers": [{
      "server": {
        "port": 80,
        "host": "0.0.0.0"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1,
        "maxConnections": 0
      }
    }, {
      "server": {
        "port": 443,
        "host": "0.0.0.0",
        "key_file_name": "/etc/ssl/certs/key.pem",
        "cert_file_name": "/etc/ssl/certs/crt.pem",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }
  ],

  "tracker": {
    "maxOffers": 20,
    "announceInterval": 120
  },

  "websocketsAccess": {
    "allowOrigins": ["https://website.com"],
    "denyEmptyOrigin": true
  }
}

Adding firewall rules

firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --reload firewall-cmd --zone=public --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: dhcpv6-client ssh
  ports: 80/tcp 443/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

Creating Service

vi /etc/systemd/system/wt-tracker.service

Description=WebTorrent Tracker

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
WorkingDirectory=/usr/local/wt-tracker
ExecStart=/usr/local/wt-tracker/bin/wt-tracker

[Install]
WantedBy=multi-user.target

Activating and Enabling Service

systemctl enable wt-tracker systemctl restart wt-tracker systemctl status wt-tracker

● wt-tracker.service - WebTorrent Tracker
   Loaded: loaded (/etc/systemd/system/wt-tracker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-05-30 12:29:55 CEST; 30min ago
 Main PID: 896 (node)
   CGroup: /system.slice/wt-tracker.service
           └─896 node /usr/local/wt-tracker/bin/wt-tracker

May 30 12:29:55 localhost systemd[1]: Started WebTorrent Tracker.
May 30 12:29:55 localhost wt-tracker[896]: listening 0.0.0.0:80
May 30 12:29:55 localhost wt-tracker[896]: listening 0.0.0.0:443

Increasing Open File Limit for Service

_#This changes will fix Error: EMFILE: too many open files, uv_resident_set_memory_

mkdir /etc/systemd/system/wt-tracker.service.d/ vi /etc/systemd/system/wt-tracker.service.d/limits.conf

[Service]
LimitNOFILE=65535

systemctl daemon-reload systemctl restart wt-tracker.service

Checking Stats

https://127.0.0.1/stats.json

{
  "torrentsCount": 0,
  "peersCount": 0,
  "servers": [
    {
      "server": "0.0.0.0:80",
      "webSocketsCount": 0
    },
    {
      "server": "0.0.0.0:443",
      "webSocketsCount": 0
    }
  ],
  "memory": {
  }
}
InvokerMaster commented 4 years ago

Did websocket connection succeed when you try to use it?

I am getting this error failed: Connection closed before receiving a handshake response

stevenking888 commented 3 years ago

Very great tutorial. you are the man.

F3rnandoJG commented 1 year ago

You made an excellent tutorial that should have come with the package, thanks, the original tutorial is very bad or for expert users.