scripts: Add start/stop scripts for slow simapp

This commit is contained in:
willclarktech 2021-04-08 12:20:33 +02:00
parent 5fcfb1d74a
commit 4d9ec5c61f
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
3 changed files with 54 additions and 0 deletions

View File

@ -2,3 +2,4 @@
REPOSITORY="interchainio/simapp"
VERSION="v0.42.1"
CONTAINER_NAME="simapp"
CONTAINER_NAME_SLOW="simapp-slow"

42
scripts/simapp/start_slow.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"
# Please keep this in sync with the Ports overview in HACKING.md
TENDERMINT_PORT_GUEST="26657"
TENDERMINT_PORT_HOST="26660"
API_PORT_GUEST="1317"
API_PORT_HOST="1320"
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
# shellcheck source=./env
# shellcheck disable=SC1091
source "$SCRIPT_DIR"/env
TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/simapp_slow.XXXXXXXXX")
chmod 777 "$TMP_DIR"
echo "Using temporary dir $TMP_DIR"
SIMD_LOGFILE="$TMP_DIR/simd_slow.log"
# Use a fresh volume for every start
docker volume rm -f simapp_slow_data
docker run --rm \
--name "$CONTAINER_NAME_SLOW" \
-p "$TENDERMINT_PORT_HOST":"$TENDERMINT_PORT_GUEST" \
-p "$API_PORT_HOST":"$API_PORT_GUEST" \
--mount type=bind,source="$SCRIPT_DIR/template_slow",target=/template \
--mount type=volume,source=simapp_slow_data,target=/root \
"$REPOSITORY:$VERSION" \
/template/run_simd.sh \
>"$SIMD_LOGFILE" 2>&1 &
echo "slow simd running on http://localhost:$TENDERMINT_PORT_HOST and logging into $SIMD_LOGFILE"
if [ -n "${CI:-}" ]; then
# Give process some time to come alive. No idea why this helps. Needed for CI.
sleep 0.5
# Follow the logs in CI's background job
tail -f "$SIMD_LOGFILE"
fi

11
scripts/simapp/stop_slow.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
# shellcheck source=./env
# shellcheck disable=SC1091
source "$SCRIPT_DIR"/env
echo "Killing slow simapp container..."
docker container kill "$CONTAINER_NAME_SLOW"