From 19fcd3368f98f964c34064b0e63769134254df23 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 14 Mar 2024 10:34:08 -0400 Subject: [PATCH] feat: redirect output in every case as appropriate --- dokku | 3 ++- plugins/common/functions | 5 +++++ plugins/git/internal-functions | 18 ++++++++++++++++++ plugins/git/receive-app | 5 +++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dokku b/dokku index b6912a8e5..067cc550e 100755 --- a/dokku +++ b/dokku @@ -188,7 +188,8 @@ execute_dokku_cmd() { set -- "$PLUGIN_CMD" "$@" fi - if [[ $PLUGIN_NAME =~ git-* ]] || [[ $PLUGIN_NAME =~ git:* ]]; then + if [[ $PLUGIN_NAME =~ git-* ]] || [[ "$PLUGIN_NAME" == "ps:rebuild" ]] || [[ "$PLUGIN_NAME" == "ps:restart" ]] || [[ "$PLUGIN_NAME" == "deploy" ]]; then + export DOKKU_REDIRECT_OUTPUT=true exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) fi diff --git a/plugins/common/functions b/plugins/common/functions index 9a7e12c84..9a3501a5a 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -626,6 +626,11 @@ release_and_deploy() { declare desc="main function for releasing and deploying an app" source "$PLUGIN_AVAILABLE_PATH/config/functions" + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi + local APP="$1" local IMAGE_TAG="${2:-latest}" local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG") diff --git a/plugins/git/internal-functions b/plugins/git/internal-functions index 5641cd923..c17a31042 100755 --- a/plugins/git/internal-functions +++ b/plugins/git/internal-functions @@ -52,6 +52,10 @@ cmd-git-from-archive() { dokku_log_fail "Invalid archive type specified, valid archive types include: tar, tar.gz, zip" fi + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi plugn trigger git-from-archive "$APP" "$ARCHIVE_URL" "$ARCHIVE_TYPE" "$USER_NAME" "$USER_EMAIL" plugn trigger deploy-source-set "$APP" "$ARCHIVE_TYPE" "$ARCHIVE_URL" } @@ -124,6 +128,10 @@ cmd-git-load-image() { [[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image" [[ ! -t 0 ]] || dokku_log_fail "Expecting tar archive containing docker image on STDIN" + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi cat | docker load if ! verify_image "$DOCKER_IMAGE"; then @@ -168,6 +176,11 @@ cmd-git-from-image() { verify_app_name "$APP" [[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image" + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi + if ! plugn trigger git-from-image "$APP" "$DOCKER_IMAGE" "$BUILD_DIR" "$USER_NAME" "$USER_EMAIL"; then return 1 fi @@ -211,6 +224,11 @@ cmd-git-sync() { DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")" CURRENT_REF="$(fn-git-cmd "$APP_ROOT" rev-parse "$DOKKU_DEPLOY_BRANCH" 2>/dev/null || true)" + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi + if ! fn-git-cmd "$APP_ROOT" rev-parse "$DOKKU_DEPLOY_BRANCH" &>/dev/null; then dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF" fn-git-clone "$APP" "$GIT_REMOTE" "$GIT_REF" diff --git a/plugins/git/receive-app b/plugins/git/receive-app index ef7f59af1..78821f835 100755 --- a/plugins/git/receive-app +++ b/plugins/git/receive-app @@ -7,6 +7,11 @@ trigger-git-receive-app() { declare desc="builds the app from the local git repository" declare trigger="receive-app" + if [[ "$DOKKU_REDIRECT_OUTPUT" != "true" ]]; then + export DOKKU_REDIRECT_OUTPUT=true + exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}")) + fi + git_receive_app "$@" return $? }