From b3724716ffbb645f90663d24d6d2f50252600ec4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 24 Sep 2019 12:14:48 -0400 Subject: [PATCH] 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. --- docs/deployment/builds-management.md | 30 +++++++++++++++++++++++ plugins/builds/commands | 16 +++++++++++++ plugins/builds/internal-functions | 31 ++++++++++++++++++++++++ plugins/builds/plugin.toml | 4 ++++ plugins/builds/subcommands/cancel | 36 ++++++++++++++++++++++++++++ plugins/builds/subcommands/default | 6 +++++ plugins/builds/subcommands/list | 13 ++++++++++ plugins/builds/subcommands/output | 27 +++++++++++++++++++++ plugins/builds/subcommands/report | 15 ++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 docs/deployment/builds-management.md create mode 100755 plugins/builds/commands create mode 100755 plugins/builds/internal-functions create mode 100644 plugins/builds/plugin.toml create mode 100755 plugins/builds/subcommands/cancel create mode 100755 plugins/builds/subcommands/default create mode 100755 plugins/builds/subcommands/list create mode 100755 plugins/builds/subcommands/output create mode 100755 plugins/builds/subcommands/report diff --git a/docs/deployment/builds-management.md b/docs/deployment/builds-management.md new file mode 100644 index 000000000..cf3e779dd --- /dev/null +++ b/docs/deployment/builds-management.md @@ -0,0 +1,30 @@ +# Build Management + +> New as of 0.19.0 + +``` +builds:cancel # Cancel a running build for an app +builds:list # List all running builds +builds:output # Shows build output +builds:report [] [] # Displays a build report for one or more apps +``` + +## Usage + +### Listing running deploys + +### Viewing the status of a deploy + +### Viewing build output for a deploy + +### Canceling a running deploy + +It can be useful to kill a deploy if that deploy does not appear to be progressing, is impacting other apps through system resource utilization, or if a successful deploy will result in app errors. To do so, the `builds:cancel` command can be used: + +```shell +dokku builds:cancel node-js-app +``` + +This command will send a `QUIT` signal to the Process Group ID of the process handling the deploy, and should terminate all processes within that process tree. Finally, it will unlock the deploy so that a new deploy may be immediately invoked. + +> Warning: This may also result in invalid app state depending upon when the app deploy was killed. diff --git a/plugins/builds/commands b/plugins/builds/commands new file mode 100755 index 000000000..bbb121222 --- /dev/null +++ b/plugins/builds/commands @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +[[ " help builds:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" +source "$PLUGIN_AVAILABLE_PATH/builds/internal-functions" +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +case "$1" in + help | builds:help) + cmd-builds-help "$@" + ;; + + *) + exit "$DOKKU_NOT_IMPLEMENTED_EXIT" + ;; + +esac diff --git a/plugins/builds/internal-functions b/plugins/builds/internal-functions new file mode 100755 index 000000000..1b56fad60 --- /dev/null +++ b/plugins/builds/internal-functions @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +fn-builds-help-content() { + declare desc="return logs plugin help content" + cat <, Cancel a running build for an app + builds:list , List all running builds + builds:output , Shows build output + builds:report [] [], Displays a build report for one or more apps +help_content +} + +cmd-builds-help() { + if [[ $1 == "builds:help" ]]; then + echo -e 'Usage: dokku builds[:COMMAND]' + echo '' + echo 'Manage running builds' + echo '' + echo 'Additional commands:' + fn-builds-help-content | sort | column -c2 -t -s, + elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then + fn-builds-help-content + else + cat <