Ejecutar como un servicio
A continuación creamos los servicios para que nuestros nodos puedan ejecutarse de forma automática.
Archivo env
env
Creamos un shell script que luego utilizaremos para arrancar el nodo usando systemctl
.
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
Archivo de servicio
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.
[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
Administrar nuestro servicio
Podemos usar los siguientes comandos para administrar nuestro servicio de cardano-node.
# 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
Última actualización
¿Te fue útil?