vim /home/cardano/cnode/scripts/cnode.sh
#!/bin/bash
cardano-node run \
--database-path /home/cardano/cnode/db/ \
--socket-path /home/cardano/cnode/sockets/node.socket \
--host-addr 0.0.0.0 \
--port 3001 \
--config /home/cardano/cnode/config/mainnet-config.json \
--topology /home/cardano/cnode/config/mainnet-topology.json
sudo vim /etc/systemd/system/cnode.service
[Unit]
Description=Cardano Node
After=network.target
[Service]
Type=simple
Restart=on-failure
RestartSec=5
User=cardano
LimitNOFILE=1048576
WorkingDirectory=/home/cardano/cnode/scripts
ExecStart=/bin/bash -l -c "exec /home/cardano/cnode/scripts/cnode.sh"
ExecStop=/bin/bash -l -c "exec kill -2 $(ps -ef | grep [c]ardano-node.*./home/cardano/ | tr -s ' ' | cut -d ' ' -f2)"
KillSignal=SIGINT
SuccessExitStatus=143
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cnode
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start cnode
systemctl enable cnode
systemctl status cnode
systemctl stop cnode
systemctl restart cnode