feat: implement builds:output

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.
This commit is contained in:
Jose Diaz-Gonzalez
2024-03-14 08:00:26 -04:00
parent 64b98b766a
commit e845240cf5
3 changed files with 28 additions and 11 deletions

4
dokku
View File

@@ -188,6 +188,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

View File

@@ -34,4 +34,4 @@ cmd-builds-cancel() {
kill -quit -- "-${PROCESS_GROUP_ID}" && rm -f "$APP_DEPLOY_LOCK_FILE"
}
cmd-builds-cancel "$@"
cmd-builds-cancel "$@"

View File

@@ -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
PROCESS_ID="$(cat "$APP_DEPLOY_LOCK_FILE")"
if [[ -z "$PROCESS_ID" ]]; then
dokku_log_info1 "No matching app deploy found"
return
if [[ -z "$DEPLOY_ID" ]]; then
dokku_log_fail "No deploy id specified"
return 1
fi
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
}