Commit b129b31a authored by dgasull's avatar dgasull

Adding utility scripts

parent c9f304fa
......@@ -7,6 +7,22 @@ You can find dataClay demos at:
https://github.com/bsc-dom/dataclay-demos
## Scripts
Some useful scripts can be found here.
##### START DATACLAY (`start_dataclay.sh`)
Start dataClay before running our demo docker application.
##### STOP DATACLAY (`stop_dataclay.sh`)
Do a graceful stop of dataClay.
##### OPTIONAL: CLEAN UP (`clean.sh`)
Make sure no dataClay docker services are running and clean volumes.
## Questions?
If you have any questions, please feel free to ask to support-dataclay@bsc.es
......
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
grn=$'\e[1;32m'
blu=$'\e[1;34m'
end=$'\e[0m'
function printError {
echo "${red}======== $1 ========${end}"
}
function printMsg {
echo "${blu}======== $1 ========${end}"
}
printMsg "Removing and cleaning dataClay dockers"
pushd $SCRIPTDIR/dataclay
docker-compose kill
docker-compose down -v #sanity check
popd
printMsg "Cleaned!"
\ No newline at end of file
version: '3.4'
services:
logicmodule:
image: "bscdataclay/logicmodule:2.0"
image: "bscdataclay/logicmodule:2.1"
command: "${COMMAND_OPTS}"
ports:
- "11034:11034"
environment:
......@@ -10,15 +11,17 @@ services:
- DATACLAY_ADMIN_USER=admin
- DATACLAY_ADMIN_PASSWORD=admin
volumes:
- ./prop/global.properties:/dataclay/cfgfiles/global.properties:ro
- ./prop/log4j2.xml:/dataclay/logging/log4j2.xml:ro
- ./prop/global.properties:/home/dataclayusr/dataclay/cfgfiles/global.properties:ro
- ./prop/log4j2.xml:/home/dataclayusr/dataclay/logging/log4j2.xml:ro
stop_grace_period: 5m
healthcheck:
interval: 5s
retries: 10
test: ["CMD-SHELL", "/dataclay/health/health_check.sh"]
test: ["CMD-SHELL", "/home/dataclayusr/dataclay/health/health_check.sh"]
dsjava:
image: "bscdataclay/dsjava:2.0"
image: "bscdataclay/dsjava:2.1"
command: "${COMMAND_OPTS}"
ports:
- "2127:2127"
depends_on:
......@@ -29,10 +32,11 @@ services:
- LOGICMODULE_PORT_TCP=11034
- LOGICMODULE_HOST=logicmodule
volumes:
- ./prop/global.properties:/dataclay/cfgfiles/global.properties:ro
- ./prop/log4j2.xml:/dataclay/logging/log4j2.xml:ro
- ./prop/global.properties:/home/dataclayusr/dataclay/cfgfiles/global.properties:ro
- ./prop/log4j2.xml:/home/dataclayusr/dataclay/logging/log4j2.xml:ro
stop_grace_period: 5m
healthcheck:
interval: 5s
retries: 10
test: ["CMD-SHELL", "/dataclay/health/health_check.sh"]
test: ["CMD-SHELL", "/home/dataclayusr/dataclay/health/health_check.sh"]
\ No newline at end of file
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
grn=$'\e[1;32m'
blu=$'\e[1;34m'
red=$'\e[1;91m'
end=$'\e[0m'
function printError {
echo "${red}======== $1 ========${end}"
}
function printMsg {
echo "${blu}======== $1 ========${end}"
}
printMsg "Starting dataClay"
echo "Optional commands=$COMMAND_OPTS"
export COMMAND_OPTS=$COMMAND_OPTS
pushd $SCRIPTDIR/dataclay
docker-compose up -d
popd
# wait for dataClay to be alive
docker run --network=dataclay_default -v $PWD/app/cfgfiles/:/home/dataclayusr/dataclay/cfgfiles/:ro \
bscdataclay/client:2.1 WaitForDataClayToBeAlive 10 5
printMsg "dataClay successfully started!"
\ No newline at end of file
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
grn=$'\e[1;32m'
blu=$'\e[1;34m'
red=$'\e[1;91m'
end=$'\e[0m'
function printError {
echo "${red}======== $1 ========${end}"
}
function printMsg {
echo "${blu}======== $1 ========${end}"
}
printMsg "Stopping dataClay"
echo "Optional commands=$COMMAND_OPTS"
export COMMAND_OPTS=$COMMAND_OPTS
pushd $SCRIPTDIR/dataclay
# first stop all dataclay services that are not logicmodule
# IMPORTANT: docker-compose stop will send a SIGTERM to ask dataClay to gracefully stop first, and then wait 5 minutes to
# send a SIGKILL to kill dataClay. It is very importat to do a graceful stop of dataClay to make sure that all
# objects created are flushed!!!
# IMPORTANT: First we should stop all python services, always in the following order 1.python - 2.java - 3.logicmodule
for SERVICE in $(docker-compose ps --all --services | grep python)
do
STARTTIME=$(date +%s)
docker-compose stop $SERVICE
ENDTIME=$(date +%s)
echo "$SERVICE stopped in $(($ENDTIME - $STARTTIME)) seconds"
done
# IMPORTANT: Now all java services
for SERVICE in $(docker-compose ps --all --services | grep java)
do
STARTTIME=$(date +%s)
docker-compose stop $SERVICE
ENDTIME=$(date +%s)
echo "$SERVICE stopped in $(($ENDTIME - $STARTTIME)) seconds"
done
# IMPORTANT: finally Logic module
STARTTIME=$(date +%s)
docker-compose stop logicmodule
ENDTIME=$(date +%s)
echo "logicmodule stopped in $(($ENDTIME - $STARTTIME)) seconds"
popd
printMsg "dataClay successfully stopped!"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment