Skip to content

Commit

Permalink
Merge pull request #16 from blockpane/develop
Browse files Browse the repository at this point in the history
more docs, attempt to fix 'go install' ... again.
  • Loading branch information
blockpane authored Jul 2, 2022
2 parents b8b03c3 + 4b1ede1 commit 849df95
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 36 deletions.
25 changes: 6 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
158 changes: 150 additions & 8 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,168 @@
# 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.
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:
## 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

```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/blockpane/tenderduty
module github.com/blockpane/tenderduty/v2

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
_ "embed"
"flag"
"fmt"
td2 "github.com/blockpane/tenderduty/td2"
td2 "github.com/blockpane/tenderduty/v2/td2"
"log"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion td2/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion td2/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion td2/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion td2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion td2/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 849df95

Please sign in to comment.