English
Creating Startup Scripts
The startup script contains all the variables needed to run a cardano-node such as directory, port, db path, config file, and topology file.
Note: KES, VRF and CERT are not yet included at this stage of the guide. If you require the completed BP startup script, see the section on updating your startup script in generating keys for the BP node.
block producer node
relaynode1
1
cat > $NODE_HOME/startBlockProducingNode.sh << EOF
2
#!/bin/bash
3
DIRECTORY=$NODE_HOME
4
PORT=6000
5
HOSTADDR=0.0.0.0
6
TOPOLOGY=\${DIRECTORY}/${NODE_CONFIG}-topology.json
7
DB_PATH=\${DIRECTORY}/db
8
SOCKET_PATH=\${DIRECTORY}/db/socket
9
CONFIG=\${DIRECTORY}/${NODE_CONFIG}-config.json
10
/usr/local/bin/cardano-node run +RTS -N -A16m -qg -qb -RTS --topology \${TOPOLOGY} --database-path \${DB_PATH} --socket-path \${SOCKET_PATH} --host-addr \${HOSTADDR} --port \${PORT} --config \${CONFIG}
11
EOF
Copied!
1
cat > $NODE_HOME/startRelayNode1.sh << EOF
2
#!/bin/bash
3
DIRECTORY=$NODE_HOME
4
PORT=6000
5
HOSTADDR=0.0.0.0
6
TOPOLOGY=\${DIRECTORY}/${NODE_CONFIG}-topology.json
7
DB_PATH=\${DIRECTORY}/db
8
SOCKET_PATH=\${DIRECTORY}/db/socket
9
CONFIG=\${DIRECTORY}/${NODE_CONFIG}-config.json
10
/usr/local/bin/cardano-node run +RTS -N -A16m -qg -qb -RTS --topology \${TOPOLOGY} --database-path \${DB_PATH} --socket-path \${SOCKET_PATH} --host-addr \${HOSTADDR} --port \${PORT} --config \${CONFIG}
11
EOF
Copied!
Add execute permissions to the startup script.
block producer node
relaynode1
1
chmod +x $NODE_HOME/startBlockProducingNode.sh
Copied!
1
chmod +x $NODE_HOME/startRelayNode1.sh
Copied!
Run the following to create a systemd unit file to define yourcardano-node.service configuration.

🍰
Benefits of Using systemd for a Stake Pool

  1. 1.
    Auto-start your stake pool when the computer reboots due to maintenance, power outage, etc.
  2. 2.
    Automatically restart crashed stake pool processes.
  3. 3.
    Maximize your stake pool up-time and performance.
block producer node
relaynode1
1
cat > $NODE_HOME/cardano-node.service << EOF
2
# The Cardano node service (part of systemd)
3
# file: /etc/systemd/system/cardano-node.service
4
5
[Unit]
6
Description = Cardano node service
7
Wants = network-online.target
8
After = network-online.target
9
10
[Service]
11
User = ${USER}
12
Type = simple
13
WorkingDirectory= ${NODE_HOME}
14
ExecStart = /bin/bash -c '${NODE_HOME}/startBlockProducingNode.sh'
15
KillSignal=SIGINT
16
RestartKillSignal=SIGINT
17
TimeoutStopSec=300
18
LimitNOFILE=32768
19
Restart=always
20
RestartSec=5
21
SyslogIdentifier=cardano-node
22
23
[Install]
24
WantedBy = multi-user.target
25
EOF
Copied!
1
cat > $NODE_HOME/cardano-node.service << EOF
2
# The Cardano node service (part of systemd)
3
# file: /etc/systemd/system/cardano-node.service
4
5
[Unit]
6
Description = Cardano node service
7
Wants = network-online.target
8
After = network-online.target
9
10
[Service]
11
User = ${USER}
12
Type = simple
13
WorkingDirectory= ${NODE_HOME}
14
ExecStart = /bin/bash -c '${NODE_HOME}/startRelayNode1.sh'
15
KillSignal=SIGINT
16
RestartKillSignal=SIGINT
17
TimeoutStopSec=300
18
LimitNOFILE=32768
19
Restart=always
20
RestartSec=5
21
SyslogIdentifier=cardano-node
22
23
[Install]
24
WantedBy = multi-user.target
25
EOF
Copied!
Move the unit file to /etc/systemd/system and give it permissions.
1
sudo mv $NODE_HOME/cardano-node.service /etc/systemd/system/cardano-node.service
Copied!
1
sudo chmod 644 /etc/systemd/system/cardano-node.service
Copied!
Run the following to enable auto-starting of your stake pool at boot time.
1
sudo systemctl daemon-reload
2
sudo systemctl enable cardano-node
Copied!
Your stake pool is now managed by the reliability and robustness of systemd. Below are some commands for using systemd.

🔎
Viewing the Status of the Node Service

1
sudo systemctl status cardano-node
Copied!

🔄
Restarting the Node Service

1
sudo systemctl reload-or-restart cardano-node
Copied!

🛑
Stopping the Node Service

1
sudo systemctl stop cardano-node
Copied!

📓
Viewing and Filtering Logs

1
journalctl --unit=cardano-node --follow
Copied!
1
journalctl --unit=cardano-node --since=yesterday
Copied!
1
journalctl --unit=cardano-node --since=today
Copied!
1
journalctl --unit=cardano-node --since='2020-07-29 00:00:00' --until='2020-07-29 12:00:00'
Copied!