Run massa node as a service

Running massa node as a service increase the robust of node stability.

Implement

// download binary
cd ~
mkdir -p massa
cd massa
wget https://github.com/massalabs/massa/releases/download/MAIN.2.2/massa_MAIN.2.2_release_linux.tar.gz
tar -xvf massa_MAIN.2.2_release_linux.tar.gz
cd ./massa/massa-node/config
echo "[protocol]" > config.toml
echo "routable_ip = \"$(curl -s ifconfig.me)\"" >> config.toml

// create service
sudo tee /etc/systemd/system/massad.service > /dev/null <<EOL
[Unit]
Description=Massa Node
After=network-online.target

[Service]
User=$USER
WorkingDirectory=$HOME/massa/massa/massa-node
ExecStart=$HOME/massa/massa/massa-node/massa-node -p <>
Restart=on-failure
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOL

// start massad service
sudo systemctl daemon-reload
sudo systemctl enable massad
sudo systemctl restart massad

// check node log
sudo journalctl -f -n 100 -u massad

// if the node is started, then buy rolls and start stake
cd ../massa-client/
screen -S massa-client
./massa-client -p <>
get_status
wallet_info
 
// buy rolls
buy_rolls <node_address> <rolls_amount> 0.01

// start staking
node_start_staking <node_address>

// wait 1 hour 40 minutes

// check staking status
get_addresses <node_address>

Upgrade

Firstly, need to know the target version.

cd ~/massa
cd ..
wget https://github.com/massalabs/massa/releases/download/MAIN.2.2/massa_MAIN.2.2_release_linux.tar.gz

tar zxvf massa_MAIN.2.2_release_linux.tar.gz

sudo systemctl stop massad && sudo systemctl start massad

sudo journalctl -f -n 100 -u massad

After upgrade, needs over 2 hours (more than 3 epochs) to wait for the rolls back to balance as MAS. Then need to buy rolls again:

buy_rolls <node_address> <rolls_amount> 0.01

No need to run stake command again. The rolls will become active after 3 epochs (about 1hour 40minutes).

AutoBuyRolls

The AutoBuyRolls bot will monitor your balance and automatically purchase rolls when necessary, eliminating the need for manual intervention.

AutoBuyRolls

Last updated