#!/usr/bin/env bash
set -x
THIS_SCRIPT=$(basename $0)
WORK_DIR=$(cd $(dirname $0); pwd)
if [ -z "${GEODE_HOME}" ]; then
GEODE_HOME=${PWD}/geode-assembly/build/install/apache-geode
fi
GFSH=${GEODE_HOME}/bin/gfsh
function checkGFSH() {
if [ -z "$GFSH" ]; then
echo "GFSH env variable not set"
exit 1
fi
if [ ! -e "$GFSH" ]; then
echo "GFSH env variable does not point at an executable"
exit 1
fi
}
function startServer() {
local X=$1
local SERVER_PORT=$2
local DEBUG_PORT=$((5004 + X))
checkGFSH
pkill -9 -f "start server${X}"
rm -rf server${X}
$GFSH start server \
--name=server${X} \
--locator-wait-time=120 \
--hostname-for-clients=localhost \
--server-port=$SERVER_PORT \
--log-level=info \
--locators=locator1[10334] \
--J=-Dgemfire.statistic-archive-file=statistics-${X}.gfs \
--J=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${DEBUG_PORT}
tail -f server${X}/server${X}.log
}
function startLocator() {
checkGFSH
rm -rf locator1
$GFSH start locator \
--name=locator1 \
--J=-Dgemfire.jmx-manager-bind-address=0.0.0.0 \
--J=-Dgemfire.jmx-manager-hostname-for-clients=localhost
tail -f locator1/locator1.log
}
case "$1" in
locator)
pushd ${WORK_DIR}
startLocator
popd
exit 0
;;
server1)
pushd ${WORK_DIR}
startServer 1 40404
popd
exit 0
;;
server2)
pushd ${WORK_DIR}
startServer 2 40405
popd
exit 0
;;
esac
docker stop -t 0 locator1 server1 server2 2>/dev/null
docker rm locator1 server1 server2 2>/dev/null
docker network rm geode-net 2>/dev/null
docker network create geode-net 2>/dev/null
DOCKER_IMAGE=bellsoft/liberica-openjdk-debian:11
docker run -d \
--name=locator1 \
-e GEODE_HOME=/geode \
-v ${GEODE_HOME}:/geode \
-v ${PWD}:/work \
--network=geode-net \
--hostname=locator1 \
-p 10334:10334 \
-p 1099:1099 \
geode /work/${THIS_SCRIPT} locator
docker run -d \
--name=server1 \
-e GEODE_HOME=/geode \
-v ${GEODE_HOME}:/geode \
-v ${PWD}:/work \
--network=geode-net \
--hostname=server1 \
-p 40404:40404 \
-p 5005:5005 \
geode \
/work/${THIS_SCRIPT} server1
docker run -d \
--name=server2 \
-e GEODE_HOME=/geode \
-v ${GEODE_HOME}:/geode \
-v ${PWD}:/work \
--network=geode-net \
--hostname=server2 \
-p 40405:40405 \
-p 5006:5006 \
geode \
/work/${THIS_SCRIPT} server2
|