Automatizar Relays

Aplicar esta solución solo en los nodos relays.

Herramienta de Guild Operators group

Publicar la ip del nodo relay

cd
cd cnode-relay/scripts

Descargamos el archivo de configuración envy el script del topology topologyUpdater.sh

curl -s -o topologyUpdater.sh https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/topologyUpdater.sh
curl -s -o env https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/env
chmod 750 topologyUpdater.sh
./topologyUpdater.sh

Para el correcto funcionamiento del script, la configuración hay que establecerla en el archivo env:

vim env

Ejemplo de configuración:

CCLI="${HOME}/.local/bin/cardano-cli"                  # Override automatic detection of path to cardano-cli executable
#CNCLI="${HOME}/.cargo/bin/cncli"                       # Override automatic detection of path to cncli executable (https://github.com/AndrewWestberg/cncli)
CNODE_HOME="${HOME}/cnode"                        # Override default CNODE_HOME path (defaults to /opt/cardano/cnode)
CNODE_PORT=3001                                         # Set node port
CONFIG="${CNODE_HOME}/config/mainnet-config.json"               # Override automatic detection of node config path
SOCKET="${CNODE_HOME}/sockets/node0.socket"            # Override automatic detection of path to socket
#EKG_HOST=127.0.0.1                                     # Set node EKG host
EKG_PORT=12798                                         # Override automatic detection of node EKG port
#EKG_TIMEOUT=3                                          # Maximum time in seconds that you allow EKG request to take before aborting (node metrics)
#CURL_TIMEOUT=10                                        # Maximum time in seconds that you allow curl file download to take before aborting (GitHub update process)
#BLOCKLOG_DIR="${CNODE_HOME}/guild-db/blocklog"         # Override default directory used to store block data for core node
#BLOCKLOG_TZ="UTC"                                      # TimeZone to use when displaying blocklog - https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Ejecutamos el script.

./topologyUpdater.sh

{ "resultcode": "201", "datetime":"2020-08-13 09:24:17", "clientIp": "xxx.xxx.xxx.xx", "iptype": 4, "msg": "nice to meet you" }

Vamos a usar crontab para automatizar la ejecución del script ./topologyUpdater.sh

crontab -e
15 * * * * ~/cnode-relay/scripts/topologyUpdater.sh

En crontab hemos añadido la tarea de ejecutar el script ./topologyUpdater.sh cada hora en el minuto 15. Ej. 00:25, 01:25, ... , 14:25, ... , 18:25 ...

Verificamos que se ha añadido la tarea al crontab.

crontab -u cardano -l

Después de cuatro intentos, en el archivo de logs topologyUpdater_lastresult.json, aparecerá el siguiente mensaje:

{ "resultcode": "203", "datetime":"2020-08-13 22:42:55", "clientIp": "116.122.63.124", "iptype": 4, "msg": "welcome to the topology" }

Si intentas mas de una llamada a topologyUpdater.sh en menos de una hora, recibirás el siguiente mensaje:

{ "resultcode": "504", "datetime":"2020-08-26 13:20:30", "clientIp": "89.131.17.84", "iptype": 4, "msg": "one request per hour please" }

Última actualización

¿Te fue útil?