From cddf7c07b671aa65086772a5c040b38e12ee788a Mon Sep 17 00:00:00 2001 From: kompotkot Date: Wed, 22 Sep 2021 11:29:37 +0000 Subject: [PATCH] Ethereum block sync service in deploy.bash --- crawlers/deploy/deploy.bash | 26 ++++++++++++++++++++ crawlers/deploy/ethereum-node.service | 3 +-- crawlers/deploy/ethereum-synchronize.service | 14 +++++++++++ crawlers/deploy/ethereum-trending.service | 2 +- crawlers/deploy/ethereum-txpool.service | 2 +- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 crawlers/deploy/ethereum-synchronize.service diff --git a/crawlers/deploy/deploy.bash b/crawlers/deploy/deploy.bash index 39375958..dea316cf 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" @@ -37,6 +39,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 index f6cf1519..4c22b89d 100644 --- a/crawlers/deploy/ethereum-node.service +++ b/crawlers/deploy/ethereum-node.service @@ -5,10 +5,9 @@ After=network.target [Service] User=ubuntu Group=www-data -EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env ExecStart=/usr/bin/geth --syncmode full \ --port 41381 --datadir /mnt/disks/nodes/ethereum \ - --txpool.globalslots 950000 --txpool.globalqueue 50000 \ + --txpool.globalslots 450000 --txpool.globalqueue 50000 \ --http --http.port 18375 --http.api eth,web3,txpool ExecStop=/bin/kill -s SIGINT -$MAINPID SyslogIdentifier=ethereum-node 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 56d0d165..579cc63d 100644 --- a/crawlers/deploy/ethereum-trending.service +++ b/crawlers/deploy/ethereum-trending.service @@ -8,4 +8,4 @@ User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/moonstream/crawlers/mooncrawl EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env -ExecStart=/usr/bin/bash -c '/home/ubuntu/moonstream-env/bin/python -m mooncrawl.ethcrawler trending' \ No newline at end of file +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 f37526bf..fc64c867 100644 --- a/crawlers/deploy/ethereum-txpool.service +++ b/crawlers/deploy/ethereum-txpool.service @@ -7,7 +7,7 @@ User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/moonstream/crawlers/ethtxpool EnvironmentFile=/home/ubuntu/moonstream-secrets/app.env -ExecStart=/home/ubuntu/moonstream/crawlers/ethtxpool/ethtxpool -geth http://127.0.0.1:"${MOONSTREAM_GETH_HTTP_PORT}" +ExecStart=/home/ubuntu/moonstream/crawlers/ethtxpool/ethtxpool -geth "${MOONSTREAM_IPC_PATH}" SyslogIdentifier=ethereum-txpool [Install]