From e9663caf5c1f2997e81d96ce37f399bebffbac0d Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 24 Apr 2015 10:49:18 -0700 Subject: [PATCH] updated dokku ls output with container status --- plugins/00_dokku-standard/commands | 9 ++++++--- plugins/common/functions | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index c653e0422..2c67807f2 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -111,18 +111,21 @@ case "$1" in ls) dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (echo "You haven't deployed any applications yet" && exit 1) - dokku_3col_log_info2_quiet "App Name" "Container Type" "Container Id" + dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status" for dokku_app in $dokku_apps; do APP=$(basename $dokku_app) DOKKU_APP_CIDS=$(get_container_ids $APP) + DOCKER_RUNNING_CONTAINERS=$(docker ps -q --no-trunc) if [[ -n $DOKKU_APP_CIDS ]]; then for DOKKU_APP_CID in $DOKKU_APP_CIDS; do + DOKKU_APP_CONTAINER_STATUS="stopped" + [[ $DOCKER_RUNNING_CONTAINERS =~ $DOKKU_APP_CID ]] && DOKKU_APP_CONTAINER_STATUS="running" DOKKU_APP_CONTAINER_TYPE=$(grep -l $DOKKU_APP_CID $DOKKU_ROOT/$APP/CONTAINER.* | awk -F. '{ print $2 }') - dokku_3col_log_msg "$APP" "$DOKKU_APP_CONTAINER_TYPE" "$DOKKU_APP_CID" + dokku_col_log_msg "$APP" "$DOKKU_APP_CONTAINER_TYPE" "${DOKKU_APP_CID:0:12}" "$DOKKU_APP_CONTAINER_STATUS" done else - dokku_3col_log_msg "$APP" "NOT_DEPLOYED" "NOT_DEPLOYED" + dokku_col_log_msg "$APP" "NOT_DEPLOYED" "NOT_DEPLOYED" "NOT_DEPLOYED" fi done ;; diff --git a/plugins/common/functions b/plugins/common/functions index 10df17574..7bc26b0ce 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -33,37 +33,37 @@ dokku_log_info2_quiet() { fi } -dokku_3col_log_info1() { - printf "%-30s %-30s %-30s\n" "-----> $@" +dokku_col_log_info1() { + printf "%-25s %-25s %-25s %-25s\n" "-----> $@" } -dokku_3col_log_info1_quiet() { +dokku_col_log_info1_quiet() { if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then - printf "%-30s %-30s %-30s\n" "-----> $@" + printf "%-25s %-25s %-25s %-25s\n" "-----> $@" else return 0 fi } -dokku_3col_log_info2() { - printf "%-30s %-30s %-30s\n" "=====> $@" +dokku_col_log_info2() { + printf "%-25s %-25s %-25s %-25s\n" "=====> $@" } -dokku_3col_log_info2_quiet() { +dokku_col_log_info2_quiet() { if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then - printf "%-30s %-30s %-30s\n" "=====> $@" + printf "%-25s %-25s %-25s %-25s\n" "=====> $@" else return 0 fi } -dokku_3col_log_msg() { - printf "%-30s %-30s %-30s\n" "$@" +dokku_col_log_msg() { + printf "%-25s %-25s %-25s %-25s\n" "$@" } -dokku_3col_log_msg_quiet() { +dokku_col_log_msg_quiet() { if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then - printf "%-30s %-30s %-30s\n" "$@" + printf "%-25s %-25s %-25s %-25s\n" "$@" else return 0 fi