Skip to content
Carlos Horowicz edited this page Jun 9, 2020 · 2 revisions

Instructions to run eth-netstats

Create a systemd unit to pass on environment variables for WS_SECRET and node's UV_THREADPOOL_SIZE=16 The "restart=always" line will make sure to restart it after a crash, which uses to happen.

Look for logs with journalctl -f

Pending: telegraf parser of logs and injection into influxdb

Run

systemctl daemon-reload
systemctl enable alastria
systemctl start alastria

after creation of this file /lib/systemd/system/alastria.service

[Unit]
Description=Alastria Netstats Telsius
Documentation=https://github.com/alastria
After=network.target

[Service]
Environment="WS_SECRET=:::EDITED:::"
Environment="UV_THREADPOOL_SIZE=16"
WorkingDirectory=/usr/local/src/eth-netstats/
StandardOutput=syslog
StandardError=syslog
Type=simple
User=root
ExecStart=/usr/bin/node server.js
Restart=always

[Install]
WantedBy=multi-user.target

Make sure to have a backlog of 2048 when creating the HTTP server

server.listen(80, "public-ip-address", 2048)

Have a big backlog for high traffic in /etc/sysctl.conf

net.core.netdev_max_backlog = 300000
net.ipv4.tcp_max_syn_backlog = 65536

Put an nginx websockets and https proxy in front of it to handle port 443

server {
      listen 443 default_server ssl;

      server_name alastria-netstats2.planisys.net;
      ssl_certificate /etc/ssl/certs/planisys.crt;
      ssl_certificate_key /etc/ssl/private/planisys.key;

      location / {
        root /usr/local/src/eth-netstats/dist/;
    }
}

server {
      listen 443 default_server ssl;

      server_name alastria-netstats2.planisys.net;
      ssl_certificate /etc/ssl/certs/planisys.crt;
      ssl_certificate_key /etc/ssl/private/planisys.key;

      location / {
          proxy_pass http://localhost:3000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
    }
}
Clone this wiki locally