-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_agent.sh
executable file
·63 lines (52 loc) · 1.6 KB
/
run_agent.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cleanup() {
echo "Terminating tendermint..."
if kill -0 "$tm_subprocess_pid" 2>/dev/null; then
kill "$tm_subprocess_pid"
wait "$tm_subprocess_pid" 2>/dev/null
fi
echo "Tendermint terminated"
if [ "$USE_TEST_API" = "true" ]; then
echo "Terminating test pool API..."
if kill -0 "$api_subprocess_pid" 2>/dev/null; then
kill "$api_subprocess_pid"
wait "$api_subprocess_pid" 2>/dev/null
fi
echo "Pool API terminated"
fi
}
# Load env vars
source .env
repo_path=$PWD
# Link cleanup to the exit signal
trap cleanup EXIT
# Remove previous agent if exists
if test -d optimus; then
echo "Removing previous agent build"
rm -r optimus
fi
# Remove empty directories to avoid wrong hashes
find . -empty -type d -delete
# Ensure hashes are updated
autonomy packages lock
# Fetch the agent
autonomy fetch --local --agent valory/optimus
python scripts/aea-config-replace.py
# Copy and add the keys and issue certificates
cd optimus
cp $PWD/../ethereum_private_key.txt .
autonomy add-key ethereum ethereum_private_key.txt
autonomy issue-certificates
# Run tendermint
rm -r ~/.tendermint
tendermint init > /dev/null 2>&1
echo "Starting Tendermint..."
tendermint node --proxy_app=tcp://127.0.0.1:26658 --rpc.laddr=tcp://127.0.0.1:26657 --p2p.laddr=tcp://0.0.0.0:26656 --p2p.seeds= --consensus.create_empty_blocks=true > /dev/null 2>&1 &
tm_subprocess_pid=$!
# Run testing API
if [ "$USE_TEST_API" = "true" ]; then
echo "Starting test pool API..."
python $repo_path/scripts/run_merkle_api.py > /dev/null 2>&1 &
api_subprocess_pid=$!
fi
# Run the agent
aea -s run