Skip to content

Cosmovisor

Story banner

Install Cosmovisor

  • Check go version #requirement go version above v.1.22 if you have Go v.1.22 already. Please skip install Go step.
Terminal window
cd $HOME && \
ver="1.22.0" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile && \
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bash_profile && \
source ~/.bash_profile && \
go version
  • Download install script:
Terminal window
cd $HOME
wget https://raw.githubusercontent.com/Josephtran102/Cosmovisor/refs/heads/main/init-cosmovisor.sh

Check script content:

#!/bin/bash
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <Story Home>"
exit 1
fi
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
export DAEMON_NAME=story
echo "export DAEMON_NAME=story" >> $HOME/.bash_profile
export DAEMON_HOME=$1
echo "export DAEMON_HOME=$1" >> $HOME/.bash_profile
cosmovisor init $(whereis -b story | awk '{print $2}')
mkdir $DAEMON_HOME/cosmovisor/backup
echo "export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME/cosmovisor/backup" >> $HOME/.bash_profile
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> $HOME/.bash_profile
banner
  • Run script:
Terminal window
source $HOME/.bash_profile
chmod +x init-cosmovisor.sh
./init-cosmovisor.sh $HOME/.story/story
source $HOME/.bash_profile
Terminal window
mkdir -p $HOME/.story/story/cosmovisor/genesis/bin
mkdir -p $HOME/.story/story/cosmovisor/upgrades/v0.11.0/bin
Stop node
Terminal window
sudo systemctl stop story
Download Story binary v0.11.0
Terminal window
cd $HOME
wget https://story-geth-binaries.s3.us-west-1.amazonaws.com/story-public/story-linux-amd64-0.11.0-aac4bfe.tar.gz
tar -xzvf story-linux-amd64-0.11.0-aac4bfe.tar.gz
banner banner
Copy new binary to Cosmovisor
Terminal window
# Copy new version binary to cosmovisor
cp $HOME/story-linux-amd64-0.11.0-aac4bfe/story $HOME/.story/story/cosmovisor/upgrades/v0.11.0/bin
Add Upgrade Information for new version
Terminal window
echo '{"name":"v0.11.0","time":"0001-01-01T00:00:00Z","height":1325860}' > /root/.story/story/cosmovisor/upgrades/v0.11.0/upgrade-info.json
Verify the Setup
Terminal window
# Check the new binary version
$HOME/.story/story/cosmovisor/upgrades/v0.11.0/bin/story version
banner
# Check upgrade info
cat $HOME/.story/story/cosmovisor/upgrades/v0.11.0/upgrade-info.json
banner
Update service file:
Terminal window
sudo tee /etc/systemd/system/story.service > /dev/null <<EOF
[Unit]
Description=Story Consensus Client
After=network.target
[Service]
User=root
Environment="DAEMON_NAME=story"
Environment="DAEMON_HOME=/root/.story/story"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_DATA_BACKUP_DIR=/root/.story/story/data"
Environment="UNSAFE_SKIP_BACKUP=true"
ExecStart=/root/go/bin/cosmovisor run run
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF
Terminal window
sudo systemctl daemon-reload
sudo systemctl restart story && sudo systemctl status story
banner
Terminal window
sudo journalctl -u story -f -o cat
banner
Terminal window
cosmovisor add-upgrade v0.11.0 /root/.story/story/cosmovisor/upgrades/v0.11.0/bin/story --force --upgrade-height 1325860
banner