Skip to content

Daemon process to connect Polkadot node with Vedran Load Balancer

License

Notifications You must be signed in to change notification settings

NodeFactoryIo/vedran-daemon

Repository files navigation

Vedran daemon

Daemon application for interacting with vedran load balancer.

Get vedran-daemon package

  1. Install Golang 1.13 or greater
  2. Run the command below
go get github.com/NodeFactoryIo/vedran-daemon
  1. Run vedran-daemon from your Go bin directory. For linux systems it will likely be:
~/go/bin/vedran-daemon

Note that if you need to do this, you probably want to add your Go bin directory to your $PATH to make things easier!

Usage

$ ./vedran-daemon -h
Register vedran-daemon with load balancer and start sending telemetry

Usage:
  vedran-daemon [flags]

Flags:
  -h, --help                    help for vedran-daemon
      --id string               Vedran-daemon id string (required)
      --lb string               Target load balancer url (required)
      --log-file string         Path to logfile. If not set defaults to stdout
      --log-level string        Level of logging (eg. debug, info, warn, error) (default "info")
      --node-metrics string     Polkadot node metrics url (default "localhost:9615")
      --node-rpc string         Polkadot node rpc url (default "localhost:9933")
      --node-ws string         Polkadot node ws url (default "localhost:9944")
      --payout-address string   Payout address to which reward tokens will be sent (required)

Starting daemon

First download latest prebuilt binary of vedran daemon from releases and binary for node. Daemon is expected to be started in conjuction with node and will wait for node if it is unavailable.

Node

For starting node see instructions

**NOTE node should be started with rpc cors disabled

Example: ./polkadot --rpc-cors=all

Daemon

Daemon is started by invoking binary.

For example:

  ./vedran-daemon-linux-amd64 --id UuPrCMnkni --lb https://load-balancer.com --payout-address 15MCkjt3B59dNo5reMCWWpxY8QB8VpEbYLo2xHEjuuWsSmTU

It will register to load balancer and start sending pings and metrics to load balancer. Port forwarding to local node is not needed and node and daemon can be in a private network because http tunnel is created between node and load balancer on registration which communicate via daemon used as a proxy server.

Required flags

--id - id string by which load balancer will distinguish between nodes - CAUTION this should be a unique string and should not be shared

--lb - public url of vedran load balancer

--payout-address - address of wallet to which reward tokens should be set - CAUTION - use valid address depending on network

Other flags

--log-level - log level (debug, info, warn, error) - DEFAULT [error]

--log-file - path to file in which logs will be saved - DEFAULT [stdout]

--node-metrics - local url to node metrics - DEFAULT [http://localhost:9615]

--node-rpc - local url to node rpc endpoint - DEFAULT [http://localhost:9933]

--node-ws - local url to node websocket rpc endpoint - DEFAULT [http://localhost:9944]

Docker

**NOTE: Unstable due to issue and should not be used in production

Network

For daemon and node to be able communicate with each other first a docker network should be created with:

docker network create polkadot

Node

docker run -d --restart unless-stopped \
        -v $HOME/polkadot/data:/data parity/polkadot:latest \
        --name "Test node" \
        --rpc-cors=all --rpc-external --ws-external

Daemon

docker run --network polkadot -d --restart unless-stopped nodefactory/vedran-daemon:latest
        --id unique-UuPrCMnkni --lb https://westend.vedran.nodefactory.io \
        --payout-address 15MCkjt3B59dNo5reMCWWpxY8QB8VpEbYLo2xHEjuuWsSmTU

Development

Clone

git clone [email protected]:NodeFactoryIo/vedran-daemon.git

Lint

Golangci-lint is expected to be installed.

make lint

Build

make build

Test

make test

Run daemon app with go run main.go [command].

More about different commands can be found in Usage.

License

This project is licensed under Apache 2.0: