feat: implement build tracking
The DOKKU_PID now never gets overwritten except in the case that DOKKU is executed by the sudo user. If the command ends up executing a deploy, then the pid of the `dokku` owned process - which may have been executed via sudo - will be written to the file lock, allowing future commands to interact with the original process. Additionally, the new builds plugin can be used to handle killing a build.
This commit is contained in:
9 files changed
+178
No files matched your search
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
cmd-builds-cancel() {
|
||||
declare desc="cancel a running build for an app"
|
||||
declare cmd="builds:cancel"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1"
|
||||
verify_app_name "$APP"
|
||||
|
||||
local APP_DEPLOY_LOCK_FILE PROCESS_ID PROCESS_GROUP_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
|
||||
fi
|
||||
|
||||
PROCESS_ID="$(cat "$APP_DEPLOY_LOCK_FILE")"
|
||||
if [[ -z "$PROCESS_ID" ]]; then
|
||||
dokku_log_info1 "No matching app deploy found"
|
||||
return
|
||||
fi
|
||||
|
||||
PROCESS_GROUP_ID="$(ps -o pgid= "$PROCESS_ID" || true)"
|
||||
if [[ -z "$PROCESS_ID" ]]; then
|
||||
dokku_log_info1 "No matching app deploy found"
|
||||
return
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Killing app deploy"
|
||||
kill -quit -- "-${PROCESS_GROUP_ID}" && rm -f "$DOKKU_ROOT/$APP/.deploy.lock"
|
||||
}
|
||||
|
||||
ps_kill_deploy_cmd "$@"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_AVAILABLE_PATH/builds/internal-functions"
|
||||
|
||||
cmd-builds-help "builds:help"
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
cmd-builds-list() {
|
||||
declare desc="list all running builds"
|
||||
declare cmd="builds:list"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
|
||||
}
|
||||
|
||||
cmd-builds-list "$@"
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
cmd-builds-output() {
|
||||
declare desc="shows build output"
|
||||
declare cmd="builds:output"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1"
|
||||
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
|
||||
fi
|
||||
|
||||
PROCESS_ID="$(cat "$APP_DEPLOY_LOCK_FILE")"
|
||||
if [[ -z "$PROCESS_ID" ]]; then
|
||||
dokku_log_info1 "No matching app deploy found"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-builds-output "$@"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
cmd-builds-report() {
|
||||
declare desc="displays a build report for one or more apps"
|
||||
declare cmd="builds:report"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1"
|
||||
verify_app_name "$APP"
|
||||
|
||||
}
|
||||
|
||||
cmd-builds-report "$@"
|
||||
Reference in new issue
Block a user