Skip to content

Commit

Permalink
feat: implement builds:output
Browse files Browse the repository at this point in the history
This still needs tightening to ensure we don't trigger this for normal git plugin commands - as well as anything that triggers a deploy - but works in a pinch.
  • Loading branch information
josegonzalez committed Mar 14, 2024
1 parent 8c23581 commit c24dc4d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions dokku
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ execute_dokku_cmd() {
set -- "$PLUGIN_CMD" "$@"
fi

if [[ $PLUGIN_NAME =~ git-* ]] || [[ $PLUGIN_NAME =~ git:* ]]; then
exec &> >(tee >(tee | logger -i -t "dokku-${DOKKU_PID}"))
fi

if [[ -x $PLUGIN_ENABLED_PATH/$PLUGIN_NAME/subcommands/default ]]; then
"$PLUGIN_ENABLED_PATH/$PLUGIN_NAME/subcommands/default" "$@"
implemented=1
Expand Down
2 changes: 1 addition & 1 deletion plugins/builds/subcommands/cancel
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ cmd-builds-cancel() {
kill -quit -- "-${PROCESS_GROUP_ID}" && rm -f "$APP_DEPLOY_LOCK_FILE"
}

cmd-builds-cancel "$@"
cmd-builds-cancel "$@"
33 changes: 23 additions & 10 deletions plugins/builds/subcommands/output
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@ cmd-builds-output() {
declare desc="shows build output"
declare cmd="builds:output"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
declare APP="$1" DEPLOY_ID="$2"
verify_app_name "$APP"

local APP_DEPLOY_LOCK_FILE PROCESS_ID
APP_DEPLOY_LOCK_FILE="$DOKKU_ROOT/$APP/.deploy.lock"
if [[ ! -f "$APP_DEPLOY_LOCK_FILE" ]]; then
dokku_log_info1 "No matching app deploy found"
return
if [[ -z "$DEPLOY_ID" ]] || [[ "$DEPLOY_ID" == "current" ]]; then
local APP_DEPLOY_LOCK_FILE PROCESS_ID
APP_DEPLOY_LOCK_FILE="$DOKKU_ROOT/$APP/.deploy.lock"
if [[ ! -f "$APP_DEPLOY_LOCK_FILE" ]]; then
dokku_log_info1 "App not currently deploying"
return
fi

DEPLOY_ID="$(cat "$APP_DEPLOY_LOCK_FILE")"
if [[ -z "$DEPLOY_ID" ]]; then
dokku_log_info1 "No matching app deploy found"
return
fi
fi

if [[ -z "$DEPLOY_ID" ]]; then
dokku_log_fail "No deploy id specified"
return 1
fi

PROCESS_ID="$(cat "$APP_DEPLOY_LOCK_FILE")"
if [[ -z "$PROCESS_ID" ]]; then
dokku_log_info1 "No matching app deploy found"
return
if [[ -x /usr/bin/systemctl ]] || [[ -x /usr/local/bin/systemctl ]]; then
journalctl -n1000 -f -b -a -o cat "SYSLOG_IDENTIFIER=dokku-${DEPLOY_ID}"
else
grep "dokku-${DEPLOY_ID}" /var/log/syslog
fi
}

Expand Down

0 comments on commit c24dc4d

Please sign in to comment.