From 21003ba4675ecfad1b00fb15f702f1de00c01a87 Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Wed, 6 Jul 2016 12:25:48 +0300 Subject: [PATCH] dind: add logs action, move all container management code into Makefile --- Makefile | 2 +- tools/dev/dindctl | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e662b96c..c5d19489 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ stop-supervisor: -docker stop resin_supervisor_1 > /dev/null || true -docker rm -f --volumes resin_supervisor_1 > /dev/null || true -refresh-supervisor: +refresh-supervisor-src: echo " * Compiling CoffeeScript.." \ && coffee -c ./src \ && echo " * Restarting supervisor container.." \ diff --git a/tools/dev/dindctl b/tools/dev/dindctl index 8eed0cdc..dfd46971 100755 --- a/tools/dev/dindctl +++ b/tools/dev/dindctl @@ -2,7 +2,6 @@ set -o errexit set -o pipefail -# set -o xtrace DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) SUPERVISOR_BASE_DIR="${DIR}/../.." @@ -12,6 +11,12 @@ SUPERVISOR_IMAGE=${SUPERVISOR_IMAGE:-"registry.resindev.io/resin/${ARCH}-supervi PASSWORDLESS_DROPBEAR=${PASSWORDLESS_DROPBEAR:-"false"} SUPERVISOR_EXTRA_MOUNTS= +SUPERVISOR_LOGS=( + '/var/log/supervisor-log/go_supervisor_stdout.log' + '/var/log/supervisor-log/resin_supervisor_stdout.log' + '/var/log/supervisor-log/supervisor/supervisord.log' +) + function showHelp { echo echo " This script can be used to facilitate supervisor development. Its core feature is allowing" @@ -30,9 +35,10 @@ function showHelp { echo " PASSWORDLESS_DROPBEAR [=false]" echo " Actions:" echo " deploy build and deploy local supervisor image - you can override registry/image name with 'SUPERVISOR_IMAGE'" - echo " run [options] build dind supervisor host container, run it, then pull the configured 'SUPERVISOR_IMAGE' and run it" + echo " run [options] build dind host container, run it, then pull the configured 'SUPERVISOR_IMAGE' into the dind host and run it" echo " deployrun [options] run 'deploy' and then immediately 'run' the deployed container" echo " refresh recompile sources in './src' with 'coffee -c' and restart supervisor container on dind host" + echo " logs [-f] print out supervisor log files - use '-f' to follow instead" echo " stop stop dind supervisor host container" echo " Options:" echo " --mount-src bind-mount './src/' from local development environment into supervisor container" @@ -62,6 +68,7 @@ function runDind { shift ;; *) + echo "Warning: unknown argument: $arg" ;; esac done @@ -74,20 +81,35 @@ function runDind { run-supervisor } -case $1 in +function logs { + if [ "$1" = "-f" ]; then + docker exec -ti resin_supervisor_1 tail -f ${SUPERVISOR_LOGS[@]} + else + for log in "${SUPERVISOR_LOGS[@]}"; do + echo " == ${log} ==" + docker exec -ti resin_supervisor_1 cat "$log" + done + fi +} + +action="$1" +shift || true + +case $action in deploy) deploySupervisor ;; run) - shift runDind "$@" ;; deployrun) - shift deploySupervisor && runDind "$@" ;; refresh) - make -C "$SUPERVISOR_BASE_DIR" refresh-supervisor + make -C "$SUPERVISOR_BASE_DIR" refresh-supervisor-src + ;; + logs) + logs "$@" ;; stop) make -C "$SUPERVISOR_BASE_DIR" stop-supervisor