sudo systemctl stop 0gd.service
2. Download cosmovisor script to install
wget https://raw.githubusercontent.com/0glabs/0g-chain/dev/networks/testnet/init-cosmovisor.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <0G Home>"
exit 1
fi
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
export DAEMON_NAME=0gchaind
echo "export DAEMON_NAME=0gchaind" >> ~/.profile
export DAEMON_HOME=$1
echo "export DAEMON_HOME=$1" >> ~/.profile
cosmovisor init $(whereis -b 0gchaind | awk '{print $2}')
mkdir $DAEMON_HOME/cosmovisor/backup
echo "export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME/cosmovisor/backup" >> ~/.profile
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> ~/.profile
chmod +x init-cosmovisor.sh
./init-cosmovisor.sh /root/.0gchain
4. Edit service file to run with Cosmovisor
nano /etc/systemd/system/0gd.service
[Unit]
Description=Cosmovisor 0G Node
After=network.target
[Service]
User=root
Type=simple
ExecStart=/root/go/bin/cosmovisor run start
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
sudo systemctl daemon-reload && \
sudo systemctl enable 0gd && \
sudo systemctl restart 0gd && sudo systemctl status 0gd
tail -f /root/.0gchain/log/chain.log