Run Node as a System Service
We recommend running X1 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/x1/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/x1/configs/testnet/full-node.toml \
/etc/x1/config.toml
cp /usr/local/share/x1/configs/testnet/api-node.toml \
/etc/x1/config.toml
cp /usr/local/share/x1/configs/testnet/archive-node.toml \
/etc/x1/config.toml
cp /usr/local/share/x1/configs/testnet/validator-node.toml \
/etc/x1/config.toml
User/Group
By default, the systemd service will run as the user and group x1
with the home directory /var/lib/x1
.
You may change the user to your needs by running the following command.
# Edit the service file
sudo systemctl edit x1.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 x1.service
sudo systemctl enable x1.service
Stop the service
sudo systemctl stop x1.service
Restart the service
sudo systemctl restart x1.service
Logging
By default, logging is handled by the system's logging service.
Tail the logs
journalctl -t x1 -f
See the last 1000 lines of logs
journalctl -t x1 -n 1000
Optionally, you can configure X1 to log to a file.
# Edit the service file
sudo systemctl edit x1.service
# Add the following lines
[Service]
StandardOutput=append:/var/log/x1.log
StandardError=append:/var/log/x1.log
Console Access
# Become the x1 user
sudo su x1
# Attach to the console
x1 attach