Setting up Cosmovisor
Utilize cosmovisor for the ease in upgrades
Setting up Cosmovisor is relatively straightforward. However, it does expect certain environment variables and folder structure 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.
First, go and get Cosmovisor (recommended approach):
go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor
# or, with go >= 1.15 you can do. This is the most common:
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/[email protected]
# If required you can target a specific version:
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/[email protected]
Your installation can be confirmed with:
which cosmovisor
This will return something like:
/home/<your-user>/go/bin/cosmovisor
Building from source allows you to target a specific version of Cosmovisor, in case you do not want to run 1.0.0 yet.
You can also build from source; cosmovisor is in the main
cosmos-sdk
repo on Github, so you can use Git tags to target a specific version. This example uses a tag, v0.42.7
that refers to the Cosmos SDK, as Cosmovisor-specific tags did not exist before August 2021. The first of these was cosmovisor/v0.1.0
, and the second is the current release, cosmovisor/v1.0.0
.git clone https://github.com/cosmos/cosmos-sdk
cd cosmos-sdk
git checkout v0.42.7
make cosmovisor
cp cosmovisor/cosmovisor $GOPATH/bin/cosmovisor
cd $HOME
In the
.profile
file, usually located at ~/.profile
, add:export DAEMON_NAME=starsd
export DAEMON_HOME=$HOME/.starsd
Then source your profile to have access to these variables:
source ~/.profile
You can confirm success like so:
echo $DAEMON_NAME
It should return
starsd
.Cosmovisor expects a certain folder structure as shown below. You can install the linux utility
tree
to produce a similar output to check on your own server..
├── current -> genesis or upgrades/<name>
├── genesis