Setup Cosmovisor

For mainnet, it's recommended to use Cosmovisor to run your node. If you've not used it before, then run it during a testnet to check you can get it set up correctly.

Setting up Cosmovisor is relatively straightforward. However, it does expect certain environment variables and folder structures to be set.

Cosmovisor allows you to download binaries ahead of time for chain upgrades, meaning that you can do zero (or close to zero) downtime chain upgrades. It's also useful if your local timezone means that a chain upgrade will fall at a bad time.

Rather than having to do stressful ops tasks late at night, it's always better if you can automate them away, and that's what Cosmovisor tries to do.


Install

First, go and get cosmovisor (recommended approach):

go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0

Your installation can be confirmed with:

which cosmovisor

This will return something like:

/home/<your-user>/go/bin/cosmovisor

Add environment variables to your shell

In the .zshrc file, usually located at ~/.zshrc, add:

# cosmovisor - Gitopia
export DAEMON_NAME=banksyd
export DAEMON_HOME=$HOME/.banksy

Then source your profile to have access to these variables:

source ~/.zshrc

You can confirm success like so:

echo $DAEMON_NAME

It should return banksyd.


Set up the folder structure

Cosmovisor expects a certain folder structure:

.
├── current -> genesis or upgrades/<name>
├── genesis
   └── bin
       └── $DAEMON_NAME
└── upgrades
    └── <name>
        └── bin
            └── $DAEMON_NAME

Don't worry about current - that is simply a symlink used by Cosmovisor. The other folders will need setting up, but this is easy:

# Create Cosmovisor Folders
mkdir -p ~/.banksy/cosmovisor/genesis/bin
mkdir -p ~/.banksy/cosmovisor/upgrades

# Load Node Binary into Cosmovisor Folder
cp ~/go/bin/banksyd ~/.banksy/cosmovisor/genesis/bin

Set up genesis binary

Cosmovisor needs to know which binary to use at genesis. We put this in $DAEMON_HOME/cosmovisor/genesis/bin.

First, find the location of the binary you want to use:

which banksyd

Then use the path returned to copy it to the directory Cosmovisor expects. Let's assume the previous command returned /home/your-user/go/bin/cheqd-noded:

cp $GOPATH/bin/banksyd ~/.banksy/cosmovisor/genesis/bin

Once you're done, check the folder structure looks correct using a tool like tree.


Set up service

Commands sent to Cosmovisor are sent to the underlying binary. For example, cosmovisor version is the same as typing banksyd version.

Nevertheless, just as we would manage banksyd using a process manager, we would like to make sure Cosmovisor is automatically restarted if something happens, for example, an error or reboot.

First, create the service file:

sudo nano /etc/systemd/system/banksyd.service

Change the contents of the below to match your setup - cosmovisor is likely at ~/go/bin/cosmovisor regardless of which installation path you took above, but it's worth checking.

[Unit]
Description=cosmovisor
After=network-online.target
[Service]
User=user
ExecStart=/home/user/go/bin/cosmovisor start
Restart=always
RestartSec=3
LimitNOFILE=4096
Environment="DAEMON_NAME=banksyd"
Environment="DAEMON_HOME=/home/user/.banksy"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_LOG_BUFFER_SIZE=512"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target

Note also that we set buffer size explicitly because of a live bug in Cosmovisor before version v1.0.0. If you are using v1.0.0, you may omit that line.

In addition, the same issue can be fixed by reducing the log via env variable. If you are unsure, ask on Discord.

Start Cosmovisor

Finally, enable the service and start it.

sudo -S systemctl daemon-reload
sudo -S systemctl enable banksyd 
sudo systemctl start banksyd 

Check it is running using:

sudo systemctl status banksyd

If you need to monitor the service after launch, you can view the logs using:

journalctl -fu banksyd

Once you hit block 147740 you will have to upgrade the node. You will do this by replacing the binary and restarting the service. You can find the detailed proposal at the following link: https://explorer.nodestake.top/banksy-testnet/gov/2. The steps are as follows:

sudo systemctl stop banksyd
cd ~/composable-centauri
git fetch --all 
git checkout v3.0.0
make install 

cp $GOPATH/bin/centaurid ~/.banksy/cosmovisor/genesis/bin

You will have to change the binary name in the service file as follows:

sudo nano /etc/systemd/system/banksyd.service

[Unit]
Description=cosmovisor
After=network-online.target
[Service]
User=user
ExecStart=/home/user/go/bin/cosmovisor start
Restart=always
RestartSec=3
LimitNOFILE=4096
Environment="DAEMON_NAME=centaurid"
Environment="DAEMON_HOME=/home/user/.banksy"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_LOG_BUFFER_SIZE=512"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target

Once changed restart the service:

sudo systemctl start banksyd && journalctl -fu banksyd

Last updated

Logo

Made with ❤️ by WhisperNode // © 2024.