diff --git a/README.md b/README.md index cc4284c..f643045 100644 --- a/README.md +++ b/README.md @@ -27,28 +27,15 @@ Usage of tenderduty: file for storing state between restarts (default ".tenderduty-state.json") ``` -## Quick start +## Installing -30 second quickstart: +Detailed installation info is in the [installation doc.](docs/install.md) -if you'd prefer to containerize and not build locally, you can: +30 second quickstart if you already have Go installed: ``` -mkdir tenderduty && cd tenderduty -docker run --rm ghcr.io/blockpane/tenderduty:latest -example-config >config.yml -# edit config.yml and add chains, notification methods etc. -docker run -d --name tenderduty -p "8888:8888" -p "28686:28686" --restart unless-stopped -v $(pwd)/config.yml:/var/lib/tenderduty/config.yml ghcr.io/blockpane/tenderduty:latest -docker logs -f --tail 20 tenderduty -``` - -Or if building from source: - -``` -git clone https://github.com/blockpane/tenderduty -cd tenderduty -cp example-config.yml config.yml -# edit config.yml -go get ./... -go install +go install github.com/blockpane/tenderduty@latest +~/go/bin/tenderduty -example-config >config.yml +# edit config ~/go/bin/tenderduty ``` diff --git a/docs/README.md b/docs/README.md index 2c8f86a..3f58433 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,10 +7,10 @@ This is a tool for validators running tendermint nodes. It sends notifications w ## Detailed Documentation Topics - [Configuration File Settings](config.md) -- Partial: [Installation](install.md) +- [Installation](install.md) - TODO: [Prometheus Exports](prometheus.md) - TODO: [Setting up Discord](discord.md) -- TODO: [Setting up PagerDuty](pagerduty.md) +- Partial: [Setting up PagerDuty](pagerduty.md) - TODO: [Setting up Telegram](telegram.md) ## What does it do? diff --git a/docs/install.md b/docs/install.md index 653c77c..982685f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,10 +1,15 @@ # Installing -This documentation is incomplete. But will cover Docker, Systemd, and hopefully Akash options. For now ... +* [Docker](#docker-container) +* [Docker Compose](#docker-compose) +* [Build From Source](#building-from-source) +* [Systemd Service](#run-as-a-systemd-service-on-ubuntu) -if you'd prefer to containerize and not build locally, you can: +Contributions and corrections are welcomed here. Would be nice to add a section on Akash deployments too. -``` +## Docker Container + +```shell mkdir tenderduty && cd tenderduty docker run --rm ghcr.io/blockpane/tenderduty:latest -example-config >config.yml # edit config.yml and add chains, notification methods etc. @@ -12,15 +17,152 @@ docker run -d --name tenderduty -p "8888:8888" -p "28686:28686" --restart unless docker logs -f --tail 20 tenderduty ``` -Or if building from source: +## Docker Compose + +```shell +mkdir tenderduty && cd tenderduty + +cat > docker-compose.yml << EOF +--- +version: '3.2' +services: + + v2: + image: ghcr.io/blockpane/tenderduty:latest + command: "" + ports: + - "8888:8888" # Dashboard + - "28686:28686" # Prometheus exporter + volumes: + - home:/var/lib/tenderduty + - ./config.yml:/var/lib/tenderduty/config.yml + logging: + driver: "json-file" + options: + max-size: "20m" + max-file: "10" + restart: unless-stopped + +volumes: + home: +EOF + +docker-compose pull +docker run --rm ghcr.io/blockpane/tenderduty:latest -example-config >config.yml + +# Edit the config.yml file, and then start the container +docker-compose up -d +docker-compose logs -f --tail 20 +``` + +## Building from source + +*Note: building tenderduty requires go v1.18 or later* + +### Installing Go + +If you intend to build from source, you will need to install Go. There are many choices on how to do this. **The most common method is to use the official installation instructions at [go.dev](https://go.dev/doc/install),** but there are a couple of shortcuts that can also be used: + +Ubuntu: +```shell +sudo apt-get install -y snapd +sudo snap install go --classic +``` + +MacOS: using [Homebrew](https://brew.sh) +```shell +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +brew install go +``` + +### Building + +The fastest way is to just let go do all the work: + +```shell +go install github.com/blockpane/tenderduty@latest +~/go/bin/tenderduty -example-config > config.yml +# edit config.yml +~/go/bin/tenderduty +``` + +If you want to hack on the source, it's easier to clone the repo: ``` git clone https://github.com/blockpane/tenderduty cd tenderduty -git checkout release/v2 cp example-config.yml config.yml -# edit config.yml +# edit config.yml with your favorite editor go get ./... -go install -~/go/bin/tenderduty +go run main.go +``` + +## Run as a systemd service on Ubuntu + +First, create a new user + +```shell +sudo addgroup --system tenderduty +sudo adduser --ingroup tenderduty --system --home /var/lib/tenderduty tenderduty ``` + +Install Go: see [the instructions above](#installing-go). + +Install the binaries + +```shell +sudo -su tenderduty +cd ~ +echo 'export PATH=$PATH:~/go/bin' >> .bashrc +. .bashrc +go install github.com/blockpane/tenderduty@latest +tenderduty --example-config > config.yml +# Edit the config.yml with your editor of choice +exit +``` + +Now create and enable the service + +```shell +# Create the service file +sudo tee /etc/systemd/system/tenderduty.service << EOF +[Unit] +Description=Tenderduty +After=network.target +ConditionPathExists=/var/lib/tenderduty/go/bin/tenderduty + +[Service] +Type=simple +Restart=on-failure +RestartSec=120 +TimeoutSec=180 + +User=tenderduty +WorkingDirectory=/var/lib/tenderduty +ExecStart=/var/lib/tenderduty/go/bin/tenderduty + +# there may be a large number of network connections if a lot of chains +LimitNOFILE=infinity + +# extra process isolation +NoNewPrivileges=true +ProtectSystem=strict +RestrictSUIDSGID=true +LockPersonality=true +PrivateUsers=true +PrivateDevices=true +PrivateTmp=true + +[Install] +WantedBy=multi-user.target +EOF + +# Enable and start the service +sudo systemctl daemon-reload +sudo systemctl enable tenderduty +sudo systemctl start tenderduty + +# and to watch the logs, press CTRL-C to stop watching +sudo journalctl -fu tenderduty + +``` \ No newline at end of file diff --git a/go.mod b/go.mod index 2eb6437..5e6c6c4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/blockpane/tenderduty +module github.com/blockpane/tenderduty/v2 go 1.18 diff --git a/main.go b/main.go index b554f74..85d2eb3 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( _ "embed" "flag" "fmt" - td2 "github.com/blockpane/tenderduty/td2" + td2 "github.com/blockpane/tenderduty/v2/td2" "log" "os" ) diff --git a/td2/init.go b/td2/init.go index 8faa470..6a84fe8 100644 --- a/td2/init.go +++ b/td2/init.go @@ -3,7 +3,7 @@ package tenderduty import ( "embed" "fmt" - dash "github.com/blockpane/tenderduty/td2/dashboard" + dash "github.com/blockpane/tenderduty/v2/td2/dashboard" "log" "os" "strings" diff --git a/td2/rpc.go b/td2/rpc.go index 5160383..0849697 100644 --- a/td2/rpc.go +++ b/td2/rpc.go @@ -4,7 +4,7 @@ import ( "context" "errors" "fmt" - dash "github.com/blockpane/tenderduty/td2/dashboard" + dash "github.com/blockpane/tenderduty/v2/td2/dashboard" rpchttp "github.com/tendermint/tendermint/rpc/client/http" "io" "net/http" diff --git a/td2/run.go b/td2/run.go index befb391..393cf66 100644 --- a/td2/run.go +++ b/td2/run.go @@ -3,7 +3,7 @@ package tenderduty import ( "encoding/json" "fmt" - dash "github.com/blockpane/tenderduty/td2/dashboard" + dash "github.com/blockpane/tenderduty/v2/td2/dashboard" "log" "os" "os/signal" diff --git a/td2/types.go b/td2/types.go index b7e0fd9..69bed53 100644 --- a/td2/types.go +++ b/td2/types.go @@ -5,7 +5,7 @@ import ( _ "embed" "encoding/json" "fmt" - dash "github.com/blockpane/tenderduty/td2/dashboard" + dash "github.com/blockpane/tenderduty/v2/td2/dashboard" "github.com/go-yaml/yaml" rpchttp "github.com/tendermint/tendermint/rpc/client/http" "io" diff --git a/td2/ws.go b/td2/ws.go index b0c5eda..75d5065 100644 --- a/td2/ws.go +++ b/td2/ws.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - dash "github.com/blockpane/tenderduty/td2/dashboard" + dash "github.com/blockpane/tenderduty/v2/td2/dashboard" "github.com/gorilla/websocket" pbtypes "github.com/tendermint/tendermint/proto/tendermint/types" "log"