From 28c78300db88106d2cb2ad6c8fc79ad4ddcab530 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Mon, 28 Oct 2013 15:00:23 +0000 Subject: [PATCH] Improve the logs command. Check for application's existence, and add an optional -t option, to make it behave like "tail -f" or "heroku logs -t" --- AUTHORS | 1 + plugins/00_dokku-standard/commands | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 94761debf..c61e1098f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Jose Diaz-Gonzalez Leo Unbekandt Luigi Maselli Martin Weiss +Paul Lietar Rajiv Makhijani rhy-jot Richard North diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 92e73305d..81e36aefa 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -23,8 +23,21 @@ case "$1" in ;; logs) - CONTAINER=$(<$DOKKU_ROOT/$2/CONTAINER) + if [[ -z $2 ]]; then + echo "Please specify an app to run the command on" + exit 1 + fi + APP="$2"; + if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then + echo "App $APP does not exist" + exit 1 + fi + + CONTAINER=$(<$DOKKU_ROOT/$APP/CONTAINER) docker logs $CONTAINER | tail -n 100 + if [[ $3 == "-t" ]]; then + docker attach $CONTAINER + fi ;; run) @@ -56,7 +69,7 @@ case "$1" in help) cat && cat< Delete an application - logs Show the last logs for an application + logs [-t] Show the last logs for an application (-t follows) run Run a command in the environment of an application url Show the URL for an application EOF