show logs on deploy success and failure. closes #1044

This commit is contained in:
Michael Hobbs committed 2015-03-20 12:32:49 -07:00
1 parent 23b35a03b4
commit 77257c484f
3 files changed
+33 -20

No files matched your search

+13 -18
View File
@@ -54,13 +54,23 @@ WAIT="${DOKKU_CHECKS_WAIT:-5}"
# Wait this many seconds (default 30) for each response. # Wait this many seconds (default 30) for each response.
TIMEOUT="${DOKKU_CHECKS_TIMEOUT:-30}" TIMEOUT="${DOKKU_CHECKS_TIMEOUT:-30}"
# try to copy CHECKS from container if not in APP dir & quit gracefully if it doesn't exist # try to copy CHECKS from container if not in APP dir & quit gracefully if it doesn't exist
# docker cp exits with status 1 when run as non-root user when it tries to chown the file # docker cp exits with status 1 when run as non-root user when it tries to chown the file
# after successfully copying the file. Thus, we suppress stderr. # after successfully copying the file. Thus, we suppress stderr.
# ref: https://github.com/dotcloud/docker/issues/3986 # ref: https://github.com/dotcloud/docker/issues/3986
TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX) TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX)
docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS $TMPDIR 2> /dev/null || true docker cp $DOKKU_APP_CONTAINER_ID:/app/CHECKS $TMPDIR 2> /dev/null || true
FILENAME=${TMPDIR}/CHECKS
cleanup() {
rm -rf $TMPDIR
dokku_log_info2_quiet "$APP container output:"
dokku_container_log_verbose_quiet $DOKKU_APP_CONTAINER_ID
dokku_log_info2_quiet "end $APP container output"
}
trap cleanup EXIT
if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
dokku_log_verbose "CHECKS file not found in container: running simple container check..." dokku_log_verbose "CHECKS file not found in container: running simple container check..."
rm -rf $TMPDIR rm -rf $TMPDIR
@@ -72,23 +82,9 @@ if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
sleep $DOKKU_DEFAULT_WAIT sleep $DOKKU_DEFAULT_WAIT
docker ps -q --no-trunc | grep -q "$DOKKU_APP_CONTAINER_ID" || dokku_log_fail "App container failed to start!!" docker ps -q --no-trunc | grep -q "$DOKKU_APP_CONTAINER_ID" || dokku_log_fail "App container failed to start!!"
dokku_log_info1 "Default check successful!" && exit 0 dokku_log_info1 "Default container check successful!" && exit 0
fi fi
FILENAME=${TMPDIR}/CHECKS
cleanup() {
rm -rf $TMPDIR
if [[ $DOKKU_TRACE ]] ; then
dokku_log_info1 "Begin server log ..."
docker logs $DOKKU_APP_CONTAINER_ID
dokku_log_info1 "End server log\n"
fi
}
trap cleanup EXIT
# Reads name/value pairs, sets the WAIT and TIMEOUT variables # Reads name/value pairs, sets the WAIT and TIMEOUT variables
exec < "$FILENAME" exec < "$FILENAME"
while read LINE ; do while read LINE ; do
@@ -150,6 +146,7 @@ while read CHECK_URL EXPECTED ; do
# And how we formulate the CURL request # And how we formulate the CURL request
CURL_ARGS="$CURL_OPTIONS $URL_PROTOCOL://$DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT$URL_PATHNAME $HEADERS" CURL_ARGS="$CURL_OPTIONS $URL_PROTOCOL://$DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT$URL_PATHNAME $HEADERS"
dokku_log_verbose "CHECKS expected result:"
dokku_log_verbose "$LOG_URL => \"$EXPECTED\"" dokku_log_verbose "$LOG_URL => \"$EXPECTED\""
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS" [[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
@@ -167,6 +164,4 @@ while read CHECK_URL EXPECTED ; do
fi fi
done done
dokku_log_info1 "All checks successful!" dokku_log_info1 "All checks successful!"
+20
View File
@@ -69,6 +69,14 @@ dokku_col_log_msg_quiet() {
fi fi
} }
dokku_log_verbose_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
echo " $@"
else
return 0
fi
}
dokku_log_verbose() { dokku_log_verbose() {
echo " $@" echo " $@"
} }
@@ -82,6 +90,18 @@ dokku_log_fail() {
exit 1 exit 1
} }
dokku_container_log_verbose_quiet() {
CID=$1;
shift
OIFS=$IFS
IFS=$'\n'
for line in $(docker logs $CID 2>&1); do
dokku_log_verbose_quiet "$line"
done
IFS=$OIFS
}
verify_app_name() { verify_app_name() {
local APP="$1" local APP="$1"
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist" [[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
-2
View File
@@ -11,7 +11,6 @@ destroy_app(){
failed(){ failed(){
echo "************ $1 failed ************" echo "************ $1 failed ************"
dokku logs $REPO
destroy_app destroy_app
exit 1 exit 1
} }
@@ -47,5 +46,4 @@ else
fi fi
fi fi
dokku logs $REPO
destroy_app destroy_app