Ejecutar como un servicio
A continuación creamos los servicios para que nuestros nodos puedan ejecutarse de forma automática.
Creamos un shell script que luego utilizaremos para arrancar el nodo usando
systemctl
.RELAY
BLOCK
~/cardano-node/relay/env
TOPOLOGY=/home/ubuntu/cardano-node/relay/topology.json
DATABASE_PATH=/home/ubuntu/cardano-node/relay/db
SOCKET_PATH=/home/ubuntu/cardano-node/relay/db/socket
HOST_ADDR=0.0.0.0
PORT=3001
CONFIG=/home/ubuntu/cardano-node/relay/config.json
~/cardano-node/block/env
TOPOLOGY=/home/ubuntu/cardano-node/block/topology.json
DATABASE_PATH=/home/ubuntu/cardano-node/block/db
SOCKET_PATH=/home/ubuntu/cardano-node/block/db/socket
HOST_ADDR=0.0.0.0
PORT=3000
CONFIG=/home/ubuntu/cardano-node/block/config.json
SHELLEY_KES_KEY=/home/ubuntu/cardano-node/block/BP.kes.skey
SHELLEY_VRF_KEY=/home/ubuntu/cardano-node/block/BP.vrf.skey
SHELLEY_OPCERT=/home/ubuntu/cardano-node/block/BP.node.opcert
Creamos un archivo de servicio para poder programar y administrar el servicio usando
systemctl
. Debes iniciar tu editor de texto con sudo
para poder guardar los cambios a estos archivos.No usar el servicio para iniciar nuestro BP hasta después de haber generado nuestras llaves y registrado el pool. Hasta entonces se debe iniciar el nodo como un relay normal. Se incluye un un script "TEMP" como ejemplo.
RELAY
BLOCK
TEMP
/etc/systemd/system/RELAY.service
[Unit]
Description=Cardano Haskell Node - RELAY
After=syslog.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
User=ubuntu
LimitNOFILE=131072
WorkingDirectory=/home/ubuntu/cardano-node/relay
EnvironmentFile=/home/ubuntu/cardano-node/relay/env
ExecStart=/home/ubuntu/.local/bin/cardano-node \
+RTS -N -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DATABASE_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOST_ADDR} \
--port ${PORT} \
--config ${CONFIG}
KillSignal=SIGINT
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=RELAY
[Install]
WantedBy=multi-user.target
/etc/systemd/system/BLOCK.service
[Unit]
Description=Cardano Haskell Node - BLOCK
After=syslog.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
User=ubuntu
LimitNOFILE=131072
WorkingDirectory=/home/ubuntu/cardano-node/block
EnvironmentFile=/home/ubuntu/cardano-node/block/env
ExecStart=/home/ubuntu/.local/bin/cardano-node \
+RTS -N -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DATABASE_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOST_ADDR} \
--port ${PORT} \
--config ${CONFIG} \
--shelley-kes-key ${SHELLEY_KES_KEY} \
--shelley-vrf-key ${SHELLEY_VRF_KEY} \
--shelley-operational-certificate ${SHELLEY_OPCERT}
KillSignal=SIGINT
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=BLOCK
[Install]
WantedBy=multi-user.target
/etc/systemd/system/BLOCK.service
[Unit]
Description=Cardano Haskell Node - BLOCK
After=syslog.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
User=ubuntu
LimitNOFILE=131072
WorkingDirectory=/home/ubuntu/cardano-node/block
EnvironmentFile=/home/ubuntu/cardano-node/block/env
ExecStart=/home/ubuntu/.local/bin/cardano-node \
+RTS -N -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DATABASE_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOST_ADDR} \
--port ${PORT} \
--config ${CONFIG}
KillSignal=SIGINT
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=BLOCK
[Install]
WantedBy=multi-user.target
Podemos usar los siguientes comandos para administrar nuestro servicio de cardano-node.
RELAY
BLOCK
# Habilitar arranque automatico del nodo al encender el servidor
sudo systemctl enable RELAY
# Habilitar arranque automatico e iniciar servicio inmediatamente (opcional)
sudo systemctl enable --now RELAY
# Iniciar servicio
sudo systemctl start RELAY
# Detener servicio
sudo systemctl stop RELAY
# Ver estado del servicio
sudo systemctl status RELAY
# Habilitar arranque automatico del nodo al encender el servidor
sudo systemctl enable BLOCK
# Habilitar arranque automatico e iniciar servicio inmediatamente (opcional)
sudo systemctl enable --now BLOCK
# Iniciar servicio
sudo systemctl start BLOCK
# Detener servicio
sudo systemctl stop BLOCK
# Ver estado del servicio
sudo systemctl status BLOCK
¿Como crear un pool? - Anterior
Configuración de un nodo
Próximo - ¿Como crear un pool?
Keys y certificado del pool
Última actualización 1yr ago