Run Node as a System Service
We recommend running NEXT as a system service. It offers control over starting, stopping, and restarting, runs in the background, and starts automatically on boot, ensuring availability and reliability.
Configuration
Rather than providing command line flags, the system service uses a config file at /etc/next/config.toml
.
We provide ready-to-use example config files for each node type.
Run the following command to copy the example config file
cp /usr/local/share/next/configs/testnet/full-node.toml \
/etc/next/config.toml
cp /usr/local/share/next/configs/testnet/api-node.toml \
/etc/next/config.toml
cp /usr/local/share/next/configs/testnet/validator-node.toml \
/etc/next/config.toml
User/Group
By default, the systemd service will run as the user and group next
with the home directory /var/lib/next
.
You may change the user to your needs by running the following command.
# Edit the service file
sudo systemctl edit next.service
# Add the following lines with an existing
# user and group of your choice.
[Service]
User=<user>
Group=<group>
Running the Node
Start the service and enable it on boot
sudo systemctl start next.service
sudo systemctl enable next.service
Stop the service
sudo systemctl stop next.service
Restart the service
sudo systemctl restart next.service
Logging
By default, logging is handled by the system's logging service.
Tail the logs
journalctl -t next -f
See the last 1000 lines of logs
journalctl -t next -n 1000
Optionally, you can configure NEXT to log to a file.
# Edit the service file
sudo systemctl edit next.service
# Add the following lines
[Service]
StandardOutput=append:/var/log/next.log
StandardError=append:/var/log/next.log
Console Access
# Become the next user
sudo su next
# Attach to the console
./next attach