diff --git a/crawlers/deploy/deploy.bash b/crawlers/deploy/deploy.bash index 39375958..3729d184 100755 --- a/crawlers/deploy/deploy.bash +++ b/crawlers/deploy/deploy.bash @@ -14,6 +14,8 @@ PARAMETERS_ENV_PATH="${SECRETS_DIR}/app.env" AWS_SSM_PARAMETER_PATH="${AWS_SSM_PARAMETER_PATH:-/moonstream/prod}" SCRIPT_DIR="$(realpath $(dirname $0))" PARAMETERS_SCRIPT="${SCRIPT_DIR}/parameters.py" +ETHEREUM_GETH_SERVICE="ethereum-node.service" +ETHEREUM_SYNCHRONIZE_SERVICE="ethereum-synchronize.service" ETHEREUM_TRENDING_SERVICE="ethereum-trending.service" ETHEREUM_TRENDING_TIMER="ethereum-trending.service" ETHEREUM_TXPOOL_SERVICE="ethereum-txpool.service" @@ -23,7 +25,10 @@ set -eu echo echo echo "Building executable Ethereum transaction pool crawler script with Go" +EXEC_DIR=$(pwd) +cd "${APP_CRAWLERS_DIR}/ethtxpool" HOME=/root /usr/local/go/bin/go build -o "${APP_CRAWLERS_DIR}/ethtxpool/ethtxpool" "${APP_CRAWLERS_DIR}/ethtxpool/main.go" +cd "${EXEC_DIR}" echo echo @@ -37,6 +42,30 @@ echo "Retrieving deployment parameters" mkdir -p "${SECRETS_DIR}" AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" "${PYTHON}" "${PARAMETERS_SCRIPT}" extract -p "${AWS_SSM_PARAMETER_PATH}" -o "${PARAMETERS_ENV_PATH}" +echo +echo +echo "Deploy Geth service if not running already" +if systemctl is-active --quiet "${ETHEREUM_GETH_SERVICE}" +then + echo "Ethereum Geth service ${ETHEREUM_GETH_SERVICE} already running" +else + echo "Replacing Ethereum Geth service definition with ${ETHEREUM_GETH_SERVICE}" + chmod 644 "${SCRIPT_DIR}/${ETHEREUM_GETH_SERVICE}" + cp "${SCRIPT_DIR}/${ETHEREUM_GETH_SERVICE}" "/etc/systemd/system/${ETHEREUM_GETH_SERVICE}" + systemctl daemon-reload + systemctl disable "${ETHEREUM_GETH_SERVICE}" + systemctl restart "${ETHEREUM_GETH_SERVICE}" + sleep 10 +fi + +echo +echo +echo "Replacing existing Ethereum block with transactions syncronizer service definition with ${ETHEREUM_SYNCHRONIZE_SERVICE}" +chmod 644 "${SCRIPT_DIR}/${ETHEREUM_SYNCHRONIZE_SERVICE}" +cp "${SCRIPT_DIR}/${ETHEREUM_SYNCHRONIZE_SERVICE}" "/etc/systemd/system/${ETHEREUM_SYNCHRONIZE_SERVICE}" +systemctl daemon-reload +systemctl restart "${ETHEREUM_SYNCHRONIZE_SERVICE}" + echo echo echo "Replacing existing Ethereum trending service and timer with: ${ETHEREUM_TRENDING_SERVICE}, ${ETHEREUM_TRENDING_TIMER}" diff --git a/crawlers/deploy/ethereum-node.service b/crawlers/deploy/ethereum-node.service new file mode 100644 index 00000000..4c22b89d --- /dev/null +++ b/crawlers/deploy/ethereum-node.service @@ -0,0 +1,16 @@ +[Unit] +Description=Ethereum node Geth client +After=network.target + +[Service] +User=ubuntu +Group=www-data +ExecStart=/usr/bin/geth --syncmode full \ + --port 41381 --datadir /mnt/disks/nodes/ethereum \ + --txpool.globalslots 450000 --txpool.globalqueue 50000 \ + --http --http.port 18375 --http.api eth,web3,txpool +ExecStop=/bin/kill -s SIGINT -$MAINPID +SyslogIdentifier=ethereum-node + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/crawlers/deploy/ethereum-synchronize.service b/crawlers/deploy/ethereum-synchronize.service new file mode 100644 index 00000000..789bc70b --- /dev/null +++ b/crawlers/deploy/ethereum-synchronize.service @@ -0,0 +1,14 @@ +[Unit] +Description=Ethereum block with transactions synchronizer +After=network.target + +[Service] +User=ubuntu +Group=www-data +WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.ethcrawler synchronize -c 6 -j 1 +SyslogIdentifier=ethereum-synchronize + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/crawlers/deploy/ethereum-trending.service b/crawlers/deploy/ethereum-trending.service index 4358a27d..579cc63d 100644 --- a/crawlers/deploy/ethereum-trending.service +++ b/crawlers/deploy/ethereum-trending.service @@ -7,5 +7,5 @@ Type=oneshot User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl -EnvironmentFile=/home/ubuntu/mooncrawl-secrets/app.env -ExecStart=/usr/bin/bash -c '/home/ubuntu/mooncrawl-env/bin/python -m mooncrawl.ethcrawler trending' +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream-env/bin/python -m mooncrawl.ethcrawler trending \ No newline at end of file diff --git a/crawlers/deploy/ethereum-txpool.service b/crawlers/deploy/ethereum-txpool.service index 81f527d8..fc64c867 100644 --- a/crawlers/deploy/ethereum-txpool.service +++ b/crawlers/deploy/ethereum-txpool.service @@ -6,7 +6,8 @@ After=network.target User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/moonstream/crawlers/ethtxpool -ExecStart=/home/ubuntu/moonstream/crawlers/ethtxpool/ethtxpool +EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env +ExecStart=/home/ubuntu/moonstream/crawlers/ethtxpool/ethtxpool -geth "${MOONSTREAM_IPC_PATH}" SyslogIdentifier=ethereum-txpool [Install]