Skip to content

0G node

0G banner”

This guide will walk you through migrating from using 0gchaind start [flags] to using Cosmovisor to manage your 0gchaind application. Cosmovisor offers the advantage of handling upgrades automatically without manual intervention.

Stop node
Terminal window
sudo systemctl stop 0gd.service
Download cosmovisor script to install
Terminal window
wget https://raw.githubusercontent.com/0glabs/0g-chain/dev/networks/testnet/init-cosmovisor.sh

Download Cosmovisor”

  • Check Script content
Terminal window
nano init-cosmovisor.sh
Run script

Before running this script, make sure Go is loaded in your current shell session.
If you haven’t loaded Go yet, please run the following command:

Terminal window
source $HOME/.bash_profile
#requirement go version above v.1.22
go version
Terminal window
chmod +x init-cosmovisor.sh
Terminal window
./init-cosmovisor.sh /root/.0gchain
  • Reload profile
Terminal window
source ~/.profile
Vana banner Vana banner
Edit service file to run with Cosmovisor
Terminal window
sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF
[Unit]
Description=Cosmovisor 0G Node
After=network.target
[Service]
User=root
Type=simple
ExecStart=/root/go/bin/cosmovisor run start --log_output_console
Restart=on-failure
LimitNOFILE=65535
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=/root/.0gchain"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=true"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_DATA_BACKUP_DIR=/root/.0gchain/cosmovisor/backup"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
  • Reload daemon and restart node
Terminal window
sudo systemctl daemon-reload && \
sudo systemctl enable 0gd && \
sudo systemctl restart 0gd && sudo systemctl status 0gd && \
sudo journalctl -u 0gd -f -o cat
Vana banner
  • Check logs
Terminal window
tail -f /root/.0gchain/log/chain.log