Merge pull request #3559 from dokku/3553-trace-mode

Add trace:on and trace:off
This commit is contained in:
Jose Diaz-Gonzalez
2019-05-19 22:59:56 -07:00
committed by GitHub
9 changed files with 123 additions and 27 deletions

16
plugins/trace/commands Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
[[ " help trace:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/trace/internal-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | trace:help)
trace_help_cmd "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trace_help_content_func() {
declare desc="return trace plugin help content"
cat <<help_content
trace, [DEPRECATED] Enables/Disables trace mode
trace:on, Clones an app
trace:off, Create a new app
help_content
}
trace_help_cmd() {
if [[ $1 == "trace:help" ]]; then
echo -e 'Usage: dokku trace[:COMMAND]'
echo ''
echo 'Manage trace mode'
echo ''
echo 'Additional commands:'
trace_help_content_func | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
trace_help_content_func
else
cat <<help_desc
trace, Manage trace mode
help_desc
fi
}

4
plugins/trace/plugin.toml Executable file
View File

@@ -0,0 +1,4 @@
[plugin]
description = "dokku core trace plugin"
version = "0.16.4"
[plugin.config]

View File

@@ -3,23 +3,25 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
dokku_trace_cmd() {
declare desc="enables/disables DOKKU_TRACE"
trace_default_cmd() {
declare desc="enables/disables trace mode"
local cmd="trace"
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
[[ "$2" == "on" ]] || [[ "$2" == "off" ]] || {
dokku_log_fail "Valid trace options are [on/off]"
}
dokku_log_warn "Deprecated: Please use trace:on or trace:off"
if [[ "$2" == "on" ]]; then
echo "Enabling dokku trace"
dokku_log_info1 "Enabling trace mode"
echo "export DOKKU_TRACE=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE"
fi
if [[ "$2" == "off" ]]; then
echo "Disabling dokku trace"
dokku_log_info1 "Disabling trace mode"
rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_TRACE"
fi
}
dokku_trace_cmd "$@"
trace_default_cmd "$@"

15
plugins/trace/subcommands/off Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trace_off_cmd() {
declare desc="disables trace mode"
local cmd="trace"
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
dokku_log_info1 "Disabling trace mode"
rm -f "$DOKKU_ROOT/.dokkurc/DOKKU_TRACE"
}
trace_off_cmd "$@"

15
plugins/trace/subcommands/on Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trace_on_cmd() {
declare desc="enables trace mode"
local cmd="trace"
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p "$DOKKU_ROOT/.dokkurc"
dokku_log_info1 "Enabling trace mode"
echo "export DOKKU_TRACE=1" >"$DOKKU_ROOT/.dokkurc/DOKKU_TRACE"
}
trace_on_cmd "$@"