openvidu-deployment: Stop elasticsearch and kibana if external services are used

pull/567/head
cruizba 2020-11-24 19:53:54 +01:00
parent 56cbef5cc7
commit b896d1a77f
2 changed files with 38 additions and 1 deletions

View File

@ -153,6 +153,12 @@ OPENVIDU_PRO_CLUSTER_LOAD_STRATEGY=streams
# Default Value is 15 # Default Value is 15
# OPENVIDU_PRO_ELASTICSEARCH_MAX_DAYS_DELETE= # OPENVIDU_PRO_ELASTICSEARCH_MAX_DAYS_DELETE=
# If you have an external Elasticsearch and Kibana already running, put here the url to elasticsearch and kibana services.
# It is very important that both url have the port specified in the url.
# If you want to use the deployed Elasticsearch and Kibana locally, keep these variables commented.
#OPENVIDU_PRO_ELASTICSEARCH_HOST=
#OPENVIDU_PRO_KIBANA_HOST=
# Private IP of OpenVidu Server Pro # Private IP of OpenVidu Server Pro
# For example 192.168.1.101 # For example 192.168.1.101
# OPENVIDU_PRO_PRIVATE_IP= # OPENVIDU_PRO_PRIVATE_IP=
@ -296,7 +302,7 @@ OPENVIDU_CDR_PATH=/opt/openvidu/cdr
# By default ElasticSearch is configured to use "-Xms2g -Xmx2g" as Java Min and Max memory heap allocation # By default ElasticSearch is configured to use "-Xms2g -Xmx2g" as Java Min and Max memory heap allocation
# ES_JAVA_OPTS=-Xms2048m -Xmx4096m # ES_JAVA_OPTS=-Xms2048m -Xmx4096m
# Kibana And ElasticSearch Configuration # Kibana And ElasticSearch Credentials Configuration
# -------------------------- # --------------------------
# Kibana And ElasticSearch Basic Auth configuration (Credentials) # Kibana And ElasticSearch Basic Auth configuration (Credentials)
# This credentials will aso be valid for Kibana dashboard # This credentials will aso be valid for Kibana dashboard

View File

@ -183,6 +183,35 @@ generate_report() {
printf "\n" printf "\n"
} }
is_external_url() {
local URL=$1
if [[ -z "$URL" ]]; then
return 1
fi
if [[ "${URL}" == *"localhost"* ]] || [[ "${URL}" == *"127.0.0.1"* ]] || [[ "${URL}" == *"::1"* ]]; then
return 1
else
return 0
fi
}
stop_elk_if_external() {
local CONFIGURED_ELASTICSEARCH_HOST
local CONFIGURED_KIBANA_HOST
CONFIGURED_ELASTICSEARCH_HOST=$(grep -v '^#' .env | grep OPENVIDU_PRO_ELASTICSEARCH_HOST | cut -d '=' -f2)
CONFIGURED_KIBANA_HOST=$(grep -v '^#' .env | grep OPENVIDU_PRO_KIBANA_HOST | cut -d '=' -f2)
if is_external_url "${CONFIGURED_ELASTICSEARCH_HOST}"; then
printf "Configured external elasticsearch: %s" "${CONFIGURED_ELASTICSEARCH_HOST}"
printf "\n"
docker-compose stop elasticsearch
fi
if is_external_url "${CONFIGURED_KIBANA_HOST}"; then
printf "Configured external kibana: %s" "${CONFIGURED_KIBANA_HOST}"
printf "\n"
docker-compose stop kibana
fi
}
usage() { usage() {
printf "Usage: \n\t openvidu [command]" printf "Usage: \n\t openvidu [command]"
printf "\n\nAvailable Commands:" printf "\n\nAvailable Commands:"
@ -202,6 +231,7 @@ case $1 in
start) start)
docker-compose up -d docker-compose up -d
stop_elk_if_external
docker-compose logs -f openvidu-server docker-compose logs -f openvidu-server
;; ;;
@ -212,6 +242,7 @@ case $1 in
restart) restart)
docker-compose down docker-compose down
docker-compose up -d docker-compose up -d
stop_elk_if_external
docker-compose logs -f openvidu-server docker-compose logs -f openvidu-server
;; ;;