Fix bug in launch node script
This commit is contained in:
parent
62a10de372
commit
bbf9df021b
25
scripts/launch-sandboxed-node.sh
Executable file
25
scripts/launch-sandboxed-node.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
||||||
|
export TZPATH="$(dirname $script_dir)"
|
||||||
|
|
||||||
|
. $TZPATH/test/test_utils.sh
|
||||||
|
|
||||||
|
start_sandboxed_node
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
activate_alpha |& sed 's/^/## /' > /dev/stderr
|
||||||
|
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
display_aliases
|
||||||
|
|
||||||
|
echo | sed 's/^/## /' 1>&2 <<EOF
|
||||||
|
|
||||||
|
Successfully launched a sandboxed node.
|
||||||
|
|
||||||
|
Run 'tezos-client' to communicate with the sandboxed node.
|
||||||
|
Run 'tezos-sandbox-stop' to stop the node and remove the sandbox data.
|
||||||
|
|
||||||
|
EOF
|
@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
source test_utils.sh
|
|
||||||
|
|
||||||
start_sandboxed_node
|
|
||||||
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
activate_alpha
|
|
||||||
|
|
||||||
alias tezos-client="${TZCLIENT} "
|
|
@ -7,8 +7,8 @@ if [ -z "$TZPATH" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Global arrays for cleanup
|
# Global arrays for cleanup
|
||||||
if [ -z "${CLEANUP_DIS}" ]; then
|
if [ -z "${CLEANUP_DIRS}" ]; then
|
||||||
export CLEANUP_DIS=()
|
export CLEANUP_DIRS=()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${CLEANUP_PROCESSES}" ]; then
|
if [ -z "${CLEANUP_PROCESSES}" ]; then
|
||||||
@ -19,33 +19,35 @@ cleanup() {
|
|||||||
for ps in "${CLEANUP_PROCESSES[@]}"; do
|
for ps in "${CLEANUP_PROCESSES[@]}"; do
|
||||||
kill -9 $ps
|
kill -9 $ps
|
||||||
done
|
done
|
||||||
CLEANUP_PROCESSES=()
|
CLEANUP_PROCESSES=();
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
for node_dir in "${CLEANUP_DIS[@]}"; do
|
for node_dir in "${CLEANUP_DIRS[@]}"; do
|
||||||
printf "\nNode's log:\n" > /dev/stderr
|
printf "\nNode's log:\n" 1>&2
|
||||||
cat $node_dir/LOG > /dev/stderr
|
[ ! -f $node_dir/LOG ] || cat $node_dir/LOG 1>&2
|
||||||
rm -rf $node_dir
|
rm -rf $node_dir
|
||||||
done
|
done
|
||||||
CLEANUP_DIS=()
|
CLEANUP_DIRS=()
|
||||||
|
|
||||||
for client_dir in ${CLIENT_DIRS[@]}; do
|
for client_dir in ${CLIENT_DIRS[@]}; do
|
||||||
rm -rf $client_dir
|
rm -rf $client_dir;
|
||||||
done
|
done
|
||||||
CLIENT_DIRS=()
|
CLIENT_DIRS=();
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
register_dir() {
|
register_dir() {
|
||||||
CLEANUP_DIS+=("$1")
|
CLEANUP_DIRS+=("$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
make_client () {
|
make_client () {
|
||||||
client_dir="$(mktemp -d -t tezos_client.XXXXXXXXXX)"
|
client_dir="$(mktemp -d -t tezos_client.XXXXXXXXXX)"
|
||||||
echo "${TZPATH}/tezos-client -base-dir ${client_dir}"
|
echo "${TZPATH}/tezos-client -base-dir ${client_dir}"
|
||||||
}
|
}
|
||||||
TZCLIENT=$(make_client)
|
TZCLIENT_DIR="$(mktemp -d -t tezos_client.XXXXXXXXXX)"
|
||||||
TZNODE="${TZPATH}/tezos-node"
|
register_dir "${TZCLIENT_DIR}"
|
||||||
|
export TZCLIENT="${TZPATH}/tezos-client -base-dir ${TZCLIENT_DIR}"
|
||||||
|
export TZNODE="${TZPATH}/tezos-node"
|
||||||
|
|
||||||
CUSTOM_PARAM="--sandbox=${TZPATH}/test/sandbox.json"
|
CUSTOM_PARAM="--sandbox=${TZPATH}/test/sandbox.json"
|
||||||
|
|
||||||
@ -58,12 +60,15 @@ start_sandboxed_node() {
|
|||||||
|
|
||||||
data_dir="$(mktemp -d -t tezos_node.XXXXXXXXXX)"
|
data_dir="$(mktemp -d -t tezos_node.XXXXXXXXXX)"
|
||||||
register_dir "$data_dir"
|
register_dir "$data_dir"
|
||||||
${TZNODE} identity generate 0 --data-dir "${data_dir}"
|
${TZNODE} identity generate 0 --data-dir "${data_dir}" |& sed 's/^/## /' 1>&2
|
||||||
${TZNODE} config init --data-dir=${data_dir} --connections=2 --expected-pow=0.0
|
${TZNODE} config init --data-dir="${data_dir}" --connections=2 --expected-pow=0.0 |& sed 's/^/## /' 1>&2
|
||||||
${TZNODE} run --data-dir "${data_dir}" ${CUSTOM_PARAM} "$@" $default_args > "$data_dir"/LOG 2>&1 &
|
${TZNODE} run --data-dir "${data_dir}" ${CUSTOM_PARAM} "$@" $default_args > "$data_dir"/LOG 2>&1 &
|
||||||
node_pid="$!"
|
node_pid="$!"
|
||||||
CLEANUP_PROCESSES+=($node_pid)
|
CLEANUP_PROCESSES+=($node_pid)
|
||||||
echo "Created node, pid: ${node_pid}, log: $data_dir/LOG" > /dev/stderr
|
export CLEANUP_PROCESSES
|
||||||
|
echo alias tezos-client=\"${TZCLIENT} \"\;
|
||||||
|
echo alias "tezos-sandbox-stop=\"kill -9 ${node_pid}; sleep 1; rm -rf ${data_dir} ${TZCLIENT_DIR};\""
|
||||||
|
echo "## Created node, pid: ${node_pid}, log: $data_dir/LOG" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +80,8 @@ activate_alpha() {
|
|||||||
activate \
|
activate \
|
||||||
protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \
|
protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \
|
||||||
with fitness 1 \
|
with fitness 1 \
|
||||||
and key edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z
|
and key edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z \
|
||||||
|
> /dev/stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -239,3 +245,13 @@ add_bootstrap_identities() {
|
|||||||
extract_operation_hash() {
|
extract_operation_hash() {
|
||||||
grep "Operation hash is" | grep -o "'.*'" | tr -d "'"
|
grep "Operation hash is" | grep -o "'.*'" | tr -d "'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display_aliases() {
|
||||||
|
echo <<EOF
|
||||||
|
|
||||||
|
alias tezos-client="${TZCLIENT} "\;
|
||||||
|
alias tezos-sandbox-stop="kill -9 ${node_pid}; sleep 1; rm -rf ${CLEANUP_DIRS[@]}; unalias tezos-client tezos-sandbox-stop"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user