Creating Startup Scripts and Services
To run an instance of Cardano Node, create a bash script to configure options.
Also, implement Cardano Node as a systemd service. Running Cardano Node as a systemd service maximizes the uptime of your stake pool by restarting the stake pool automatically if any stake pool processes may crash, or when the computer reboots.
To create a startup script and service for an instance of Cardano Node:
On the computer hosting your block producing node, using a terminal window type the following command to navigate to the folder containing configuration files and scripts related to operating your Cardano node:
cd $NODE_HOMETo retrieve the values of the
$NODE_HOMEand$USERenvironment variables, type:
echo $NODE_HOME
echo $USERIn the folder where you navigated in step 1, using a text editor create a file named
startCardanoNode.shand then add the following contents to the file where<NodeHomeValue>is the value of your$NODE_HOMEenvironment variable that you retrieved in step 2, and<ConfigFileName>isconfig-bp.jsonon your block-producing node andconfig.jsonon all your relay nodes:
#!/bin/bash
#
# Set variables to indicate Cardano Node options
#
# Set a variable to indicate the port where the Cardano Node listens
PORT=6000
# Set a variable to indicate the local IP address of the computer where Cardano Node runs
# 0.0.0.0 listens on all local IP addresses for the computer
HOSTADDR=0.0.0.0
# Set a variable to indicate the file path to your topology file
TOPOLOGY=<NodeHomeValue>/topology.json
# Set a variable to indicate the folder where Cardano Node stores blockchain data
DB_PATH=<NodeHomeValue>/db
# Set a variable to indicate the path to the Cardano Node socket for Inter-process communication (IPC)
SOCKET_PATH=<NodeHomeValue>/db/socket
# Set a variable to indicate the file path to your main Cardano Node configuration file
CONFIG=<NodeHomeValue>/<ConfigFileName>
#
# Run Cardano Node using the options that you set using variables
#
/usr/local/bin/cardano-node run --topology ${TOPOLOGY} --database-path ${DB_PATH} --socket-path ${SOCKET_PATH} --host-addr ${HOSTADDR} --port ${PORT} --config ${CONFIG}Save and close the
startCardanoNode.shfile.To set execute permissions for the
startCardanoNode.shfile, type:
To create the folder where Cardano Node stores blockchain data, type:
To run Cardano Node as a service, using a text editor create a file named
cardano-node.serviceand then add the following contents to the file where<UserValue>is the value of your$USERenvironment variable and<NodeHomeValue>is the value of your$NODE_HOMEenvironment variable that you retrieved in step 2:
Save and close the
cardano-node.servicefile.To move the
cardano-node.servicefile to the folder/etc/systemd/systemand set file permissions, type:
To start Cardano Node as a service when the computer boots, type:
Repeat steps 1 to 10 on each computer hosting a relay node in your stake pool configuration.
Managing Services
To help administer an instance of Cardano Node running as a systemd service, use the following commands.
To view the status of the Cardano Node service, type:
To restart the Cardano Node service, type:
To stop the Cardano Node service, type:
To display and filter logs, type one of the following commands, for example:
📈 Improving Cardano Node Performance
If you are not satisfied with the performance of an instance of Cardano Node, then see the topic Configuring Runtime Options.
Last updated