Nodo como servicio
Creamos el script que ejecutará el nodo:
vim /home/cardano/cnode/scripts/cnode.sh
Le damos permisos de ejecución:
chmod +x cnode.sh
Añadimos el siguiente contenido:
#!/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
Creamos el archivo que define el servicio:
sudo vim /etc/systemd/system/cnode.service
Añadimos el siguiente contenido:
[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
Comandos para interaccionar con el servicio:
systemctl daemon-reload
systemctl start cnode
systemctl enable cnode
systemctl status cnode
systemctl stop cnode
systemctl restart cnode
Última actualización
¿Te fue útil?