Skip to content

Commit

Permalink
Added option to open logs on Docker deploy - UNIX
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Apr 3, 2020
1 parent 8da29a4 commit d075c4a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 16 deletions.
2 changes: 1 addition & 1 deletion deployment/docker/unix/docker-common.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2016, 2018 Red Hat Inc and others
# Copyright (c) 2016, 2020 Red Hat Inc and others
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
Expand Down
54 changes: 43 additions & 11 deletions deployment/docker/unix/docker-deploy.sh
Expand Up @@ -12,19 +12,51 @@
# Eurotech
###############################################################################

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. ${SCRIPT_DIR}/docker-common.sh

docker_common() {
. ${SCRIPT_DIR}/docker-common.sh
}

docker_compose() {
if [[ -n "${KAPUA_BROKER_DEBUG_PORT}" ]]; then
if [[ "${KAPUA_BROKER_DEBUG_SUSPEND}" == "true" ]]; then
KAPUA_BROKER_DEBUG_SUSPEND="y"
else
KAPUA_BROKER_DEBUG_SUSPEND="n"
fi

docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml -f ${SCRIPT_DIR}/../compose/docker-compose.broker-debug.yml up -d
else
docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml up -d
fi
}

check_if_docker_logs() {
if [[ "$1" == '--logs' ]]; then
. ${SCRIPT_DIR}/docker-logs.sh
else
echo "Unrecognised parameter: ${1}"
print_usage_deploy
fi
}

print_usage_deploy(){
echo "Usage: $(basename $0) [--logs]" >&2
}


docker_common

echo "Deploying Eclipse Kapua..."
if [ -n "${KAPUA_BROKER_DEBUG_PORT}" ]; then
if [ "${KAPUA_BROKER_DEBUG_SUSPEND}" == "true" ]; then
KAPUA_BROKER_DEBUG_SUSPEND="y"
else
KAPUA_BROKER_DEBUG_SUSPEND="n"
fi
docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml -f ${SCRIPT_DIR}/../compose/docker-compose.broker-debug.yml up -d
docker_compose || { echo "Deploying Eclipse Kapua... ERROR!"; exit 1; }
echo "Deploying Eclipse Kapua... DONE!"

if [[ -z "$1" ]]; then
echo "Run \"docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml logs -f\" for container logs"
else
docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml up -d
check_if_docker_logs $1
fi
echo "Deploying Eclipse Kapua... DONE!"
echo "Run \"docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml logs -f\" for container logs"

31 changes: 31 additions & 0 deletions deployment/docker/unix/docker-logs.sh
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2016, 2020 Red Hat Inc and others
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Red Hat Inc - initial API and implementation
# Eurotech
###############################################################################

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

docker_common() {
. ${SCRIPT_DIR}/docker-common.sh
}

docker_logs() {
docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml logs -f
}

docker_common

echo "Opening Eclipse Kapua logs..."
docker_logs || { echo "Opening Eclipse Kapua logs... ERROR!"; exit 1; }
echo "Opening Eclipse Kapua logs... DONE!"
17 changes: 13 additions & 4 deletions deployment/docker/unix/docker-undeploy.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2016, 2019 Red Hat Inc and others
# Copyright (c) 2016, 2020 Red Hat Inc and others
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -12,11 +12,20 @@
# Eurotech
###############################################################################

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. ${SCRIPT_DIR}/docker-common.sh

echo "Undeploying Eclipse Kapua..."
docker_common() {
. ${SCRIPT_DIR}/docker-common.sh
}

docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml down
docker_undeploy() {
docker-compose -f ${SCRIPT_DIR}/../compose/docker-compose.yml down
}

docker_common

echo "Undeploying Eclipse Kapua..."
docker_undeploy || { echo "Undeploying Eclipse Kapua... ERROR!"; exit 1; }
echo "Undeploying Eclipse Kapua... DONE!"

0 comments on commit d075c4a

Please sign in to comment.