Files
hpcore/cluster-start.sh
Asanka Indrajith d6acee4e09 Basic consensus implementation (#45)
Consensus for user connections, user inputs, contract outputs and time.
2019-10-26 11:46:32 -04:00

27 lines
986 B
Bash
Executable File

#!/bin/bash
# Runs the specified node contract with hpcore docker image.
# This script assumes you already have the hpcore docker image and 'hpnet' virtual docker network.
# Usage (to run the node no. 1): ./start.sh 1
# Validate the node count arg.
if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then
echo "Starting docker container..."
else
echo "Error: Please provide node ID to run."
exit 1
fi
clusterloc=$(pwd)/hpcluster
n=$1
let pubport=8080+$n
# let peerport=22860+$n #Uncomment if peer port needs to be exposed to host.
# Mount the node<id> contract directory into hpcore docker container and run.
# We specify --network=hpnet so all nodes will communicate via 'hpnet' docker virtual network.
# We specify --name for each node so it will be the virtual dns name for each node.
docker run --rm -t -i --network=hpnet --name=node${n} \
-p ${pubport}:${pubport} \
--mount type=bind,source=${clusterloc}/node${n},target=/contract \
hpcore:latest run /contract