forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/improve run iroha dev (hyperledger-iroha#1115)
PR hyperledger-iroha#1115 changes the behavior of run-iroha-dev.sh and introduces stop-iroha-dev.sh. Changes: - Each user within a system can run own docker container - Introduced script for full shutdown of container environment - stop-iroha-dev.sh - Now it is possible to reenter into the container without its recreation - run-iroha-dev.sh reports ports used on the host system for Iroha and debugger run-iroha-dev.sh now automatically picks first free port from range 50051-50101 on host system for Iroha and free port from range 20000-20100 on the host system for Debugger Signed-off-by: Igor Egorov <[email protected]>
- Loading branch information
1 parent
c609cac
commit ab26677
Showing
3 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,33 @@ | ||
#!/bin/bash | ||
|
||
function next_free_port { | ||
for port in $(seq $1 $2); | ||
do echo -ne "\035" | nc 127.0.0.1 $port > /dev/null 2>&1; [ $? -eq 1 ] && echo "$port" && break; | ||
done | ||
} | ||
|
||
CURDIR="$(cd "$(dirname "$0")"; pwd)" | ||
IROHA_HOME="$(dirname "${CURDIR}")" | ||
PROJECT=iroha${USERID} | ||
PROJECT=iroha${UID} | ||
COMPOSE=${IROHA_HOME}/docker/docker-compose.yml | ||
|
||
export G_ID=$(id -g) | ||
export U_ID=$(id -u) | ||
export COMPOSE_PROJECT_NAME=${PROJECT} | ||
|
||
docker-compose -f ${COMPOSE} up -d | ||
if [ $(docker ps -q -f name=${PROJECT}_node_1 | wc -c) -eq 0 ]; | ||
then | ||
export IROHA_PORT="$(next_free_port 50051 50101)" | ||
export DEBUGGER_PORT="$(next_free_port 20000 20100)" | ||
|
||
docker-compose -f ${COMPOSE} up -d | ||
else | ||
IROHA_DBG_PORTS="$(docker port ${PROJECT}_node_1 | sed 's/\(.*\)://' | sort -r | sed -e :a -e N -e 's/\n/:/p' -e ta)" | ||
export IROHA_PORT="$(echo ${IROHA_DBG_PORTS} | sed 's/:.*//')" | ||
export DEBUGGER_PORT="$(echo ${IROHA_DBG_PORTS} | sed 's/.*://')" | ||
fi | ||
echo "" | ||
echo "Iroha is mapped to host port ${IROHA_PORT}" | ||
echo "Debugger is mapped to host port ${DEBUGGER_PORT}" | ||
echo "" | ||
docker-compose -f ${COMPOSE} exec node /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
CURDIR="$(cd "$(dirname "$0")"; pwd)" | ||
IROHA_HOME="$(dirname "${CURDIR}")" | ||
PROJECT=iroha${UID} | ||
COMPOSE=${IROHA_HOME}/docker/docker-compose.yml | ||
|
||
# actual values of are not needed here, but variables need to be defined | ||
export IROHA_PORT=1 | ||
export DEBUGGER_PORT=2 | ||
|
||
docker-compose -f ${COMPOSE} -p ${PROJECT} down |