Note: These instructions assume you already have an existing chain binary (e.g., injectived) and a working Go environment if you choose to install Cosmovisor from source. Adjust the names and paths as needed for your specific setup.
Table of Contents
- Installation
- Environment Variables
- Directory Structure
- Running Cosmovisor
- Handling Chain Upgrades
- Running Cosmovisor as a Systemd Service
Installation
Installing via Go
If you have Go installed, you can install Cosmovisor with the following command:Tip: Ensure that your Go binary installation path (commonly$GOPATH/binor$HOME/go/bin) is added to your system’sPATH. You can verify the installation by running:
Environment Variables
Set up the following environment variables so that Cosmovisor knows which binary to run and where to locate it:-
DAEMON_NAME
The name of your chain’s binary (e.g.,injectived). -
DAEMON_HOME
The home directory for your node (e.g.,~/.injectived).
~/.bashrc or ~/.profile) or export them directly in your terminal session:
Directory Structure
Cosmovisor expects a specific folder structure in your node’s home directory:-
Create the Genesis Directory
This directory holds the initial (genesis) binary.
-
Copy Your Current Binary
Place your current chain binary (e.g.,
injectived) into the genesis folder. Make sure the file name matches theDAEMON_NAMEvalue (see next section).
Running Cosmovisor
Instead of running your chain’s binary directly, start your node with Cosmovisor by executing:- Look for the binary in
$DAEMON_HOME/cosmovisor/genesis/bin(or the appropriate upgrade folder). - Start your node using that binary.
- Monitor for any on-chain upgrade signals and automatically switch binaries when needed.
Handling Chain Upgrades
When an upgrade is announced on-chain, prepare the new binary so Cosmovisor can switch to it automatically:-
Create an Upgrade Directory
Use the upgrade name provided on-chain (e.g.,
v1.14.0): -
Place the New Binary
Compile or download the new binary, then copy it into the upgrade directory. Ensure the binary name matches
DAEMON_NAME.
TIP: If you have downloaded theinjectivedbinary package from GitHub, we copylibwasmvm.x86_64.soto the upgradebindirectory. An environment variable will be later added to the systemd service to add this directory toLD_LIBRARY_PATH.
- Upgrade Process When the upgrade height is reached, Cosmovisor will detect the scheduled upgrade and automatically switch to the binary located in the corresponding upgrade folder.
Running Cosmovisor as a Systemd Service
For production environments, it is common to run your node as a systemd service. Below is an example service file.-
Create the Service File
Create a file (e.g.,
/etc/systemd/system/injectived.service) with the following content. Adjust the paths and<your_username>accordingly: -
Enable and Start the Service
-
Check Logs
Verify that your service is running smoothly: