4 SystemD setup for running a Nimbus beacon node
zah edited this page 2020-08-04 15:08:48 +03:00
  1. Clone https://github.com/status-im/nim-beacon-chain and https://github.com/Alethio/eth2stats-client next to each other and follow their respective build instructions. Resulting binaries should appear in nim-beacon-chain/build/beacon_node and eth2stats-client/eth2stats-client.

  2. Create an executable script named run_nimbus_node.sh, placed next to the cloned repositories:

#!/bin/bash

set +e

trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

cd $(dirname "$0")
cd nim-beacon-chain

NETWORK=$1
NODE_NAME=${NODE_NAME:-$(whoami)}

if [[ "$2" == "" ]]; then
  NODE_ID=0
else
  NODE_ID=$2
  NODE_NAME=$NODE_NAME-$2
fi

let METRICS_PORT=8008+${NODE_ID}
let RPC_PORT=9190+${NODE_ID}

mkdir -p /tmp/e2s-$ID
../eth2stats-client/eth2stats-client run \
  --data.folder=/tmp/${NODE_NAME} \
  --eth2stats.node-name="${NODE_NAME}" \
  --eth2stats.addr="grpc.${NETWORK}.eth2stats.io:443" --eth2stats.tls=true \
  --beacon.type="nimbus" \
  --beacon.addr="http://localhost:$RPC_PORT" \
  --beacon.metrics-addr="http://localhost:$METRICS_PORT/metrics" > /tmp/ethstats.$NODE_NAME.log 2>&1 &

make NIMFLAGS="-d:insecure" NODE_ID=$NODE_ID ${NETWORK}

Tip: Don't forget to mark the script as executable by running chmod +x on it.

  1. Create a SystemD service unit file placed at /etc/systemd/system/nbc.service with the following content:
[Unit]
Description=Nimbus beacon node

[Service]
ExecStart=<BASE-DIRECTORY>/run_nimbus_node.sh medalla
User=<USERNAME>
Group=<USERNAME>
Restart=always
RuntimeMaxSec=10800

[Install]
WantedBy=default.target

Make sure to replace <BASE-DIRECTORY> and <USERNAME> in the example above with the location where the repositories were cloned and the system user that will be responsible for running the launched processes respectively.

  1. Make SystemD aware of the newly added service by executing sudo systemctl daemon-reload.

  2. Start the NBC service with sudo systemctl enable nbc --now