Hi guys,
I don’t know how you guys check the node log when running as a service, but cardano-service status
isn’t a good way in my opinion.
EDIT: This was only tested on Ubuntu.
Okay so first of all I made the node run as a service following these steps:
-
Create the start file the systemd service will be executing
cd .local/bin
sudo nano cardano-service
-
Add this in the file for Relays WARNING: Pay attention to the paths and especially DB location, if db is in another location you can create a new path variable resembling FILES.
#!/bin/bash
FILES=/home/[USER]/PATH-TO/FILES
PORT=3000
HOSTADDR=0.0.0.0
TOPOLOGY=${FILES}/mainnet-topology.json
DB_PATH=${FILES}/db
SOCKET_PATH=${FILES}/db/socket
CONFIG=${FILES}/mainnet-config.json
cardano-node run \
--topology ${TOPOLOGY} \
--database-path ${DB_PATH}
--socket-path ${SOCKET_PATH} \
--host-addr ${HOSTADDR} \
--port ${PORT} \
--config ${CONFIG}
- For your Block Producer use this and make sure the certificate and key paths are correct.
#!/bin/bash
FILES=/home/[USER]/PATH-TO/FILES
PORT=3000
HOSTADDR=0.0.0.0
TOPOLOGY=${FILES}/mainnet-topology.json
DB_PATH=${FILES}/db
SOCKET_PATH=${FILES}/db/socket
CONFIG=${FILES}/mainnet-config.json
KEYS=${FILES}/keys
KES_KEY=${KEYS}/kes.skey
VRF_KEY=${KEYS}/vrf.skey
CERTIFICATE=${KEYS}/certificates/node.cert
cardano-node run \
--topology ${TOPOLOGY} \
--database-path ${DB_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOSTADDR} \
--port ${PORT} \
--config ${CONFIG} \
--shelley-kes-key ${KES_KEY} \
--shelley-vrf-key ${VRF_KEY} \
--shelley-operational-certificate ${CERTIFICATE}
-
Make sure you allow this file to be executed
sudo chmod +x cardano-service
-
Test if the node starts properly first by executing this in a tmux window
./cardano-service
-
If it works properly leave that tmux window (CTRL+B D) and stop the node (so it starts faster next time)
killall -s SIGINT cardano-node
-
Create the service file
sudo nano /etc/systemd/system/cardano-node.service
-
Paste (RClick) this content and edit the paths
# The Cardano Node Service (part of systemd)
# file: /etc/systemd/system/cardano-node.service
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
[Service]
User = [USER RUNNING THE NODE:] ex: ada
Type = simple
WorkingDirectory= /home/[USER]/PATH-TO-NODE-FOLDER
ExecStart = /bin/bash -c "PATH=/home/[USER]/.local/bin:$PATH exec /home/USER/.local/bin/cardano-service"
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=3
LimitNOFILE=32768
Restart=always
RestartSec=5
[Install]
WantedBy= multi-user.target
-
Save the file and reload Daemons
sudo systemctl daemon-reload
-
To avoid needing to call
sudo systemctl
we can edit .bashrc
sudo nano $HOME/.bashrc
and add the following lines
cardano-service() {
sudo systemctl "$1" cardano-node.service
}
-
Enable the changes made
source $HOME/.bashrc
-
Enable and start the service NOTE: execute these commands one by one to avoid problems
cd $HOME
cardano-service enable
cardano-service start
cardano-service status
- You can get a view from what your node is doing with
cardano-service status
, but I advise to use journalctl
(You can download ccze for colors)
sudo apt install ccze
journalctl -f --output=cat -u cardano-node.service | ccze -A
-f for following live
–output=cat to remove user and timestamps
-u to only follow cardano-node.service
-
You can put this in a file like for example
monitor.sh
,chmod +x
it and ./ it everytime you want to monitor/debug stuff from your node. -
Don’t forget you can change
minSeverity: Info
in mainnet-config.json, the options from more to less notifications are:Debug
,Info
,Notice
andWarning
andError
I hope I could help somebody with this and good luck!
P.S. For edits/improvements let me know!
Grtz Mex
Sources:
https://docs.cardano.org/projects/cardano-node/en/latest/logging-monitoring/logging.html