Run the Node with Systemd
Running the node with a manual shell command is fine for ensuring things work. However, for stable operations we're going to want to configure the node to run automatically. To accomplish this we are going to create a startup script and a systemd service that uses that script to start and run the node when the system boots. First let's create a startup script.
cd ~/preprodnet/scripts
nano node.shUse the following snippet as a template for your startup script. Please read carefully.
#!/bin/bash
#
# We will set a few variables to shorten our launch command
# Database Path
DB=/home/preprod/preprodnet/db
# Socket Path
SOCKET=/home/preprod/preprodnet/socket/node.socket
# Configuration File
CONFIG=/home/preprod/preprodnet/config/config.json
# Topology File
TOPOLOGY=/home/preprod/preprodnet/config/topology.json
# Host Address. We will set this to 'listen' for incoming connections
HOST=0.0.0.0
# Please change <your port> to the port for either your block producing node or relay
PORT=<your port>
#
# Command to run the node
#
/home/preprod/preprodnet/bin/cardano-node run --topology $TOPOLOGY --database-path $DB --socket-path $SOCKET --port $PORT --config $CONFIG --host-addr $HOSTctrl+o to save and ctrl+x to exit. Make the script executable.
Test and execute your script.

ctrl+c to stop the node.
Next we will create the service file for systemd.
Add the following text to the file you are creating with nano.
ctrl+o to save, ctrl+x to exit. Let's copy the file where it needs to go and give it the right permissions.
Start the service.
Check to ensure the service is active.

Now we will enable the service so it runs everytime the system boots.
Now let's run our first cardano-cli command and query the tip.

Last updated