mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #2617 from dokku/2356-checks-report
Implement checks:report
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
checks <app> Show zero-downtime status
|
||||
checks:disable <app> [process-type(s)] Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments***
|
||||
checks:enable <app> [process-type(s)] Enable zero-downtime deployment for all processes (or comma-separated process-type list)
|
||||
checks:report [<app>] [<flag>] Displays a checks report for one or more apps
|
||||
checks:run <app> [process-type(s)] Runs zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
checks:skip <app> [process-type(s)] Skip zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
```
|
||||
@@ -61,6 +62,46 @@ dokku checks:disable node-js-app worker
|
||||
DOKKU_CHECKS_SKIPPED: web
|
||||
```
|
||||
|
||||
### Displaying checks reports about an app
|
||||
|
||||
> New as of 0.8.1
|
||||
|
||||
You can get a report about the app's checks status using the `checks:report` command:
|
||||
|
||||
```shell
|
||||
dokku checks:report
|
||||
```
|
||||
|
||||
```
|
||||
=====> search checks information
|
||||
Checks disabled list: none
|
||||
Checks skipped list: none
|
||||
=====> python-sample checks information
|
||||
Checks disabled list: none
|
||||
Checks skipped list: none
|
||||
=====> ruby-sample checks information
|
||||
Checks disabled list: _all_
|
||||
Checks skipped list: none
|
||||
```
|
||||
|
||||
You can run the command for a specific app also.
|
||||
|
||||
```shell
|
||||
dokku checks:report node-js-sample
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-sample checks information
|
||||
Checks disabled list: none
|
||||
Checks skipped list: none
|
||||
```
|
||||
|
||||
You can pass flags which will output only the value of the specific information you want. For example:
|
||||
|
||||
```shell
|
||||
dokku checks:report node-js-sample --checks-disabled-list
|
||||
```
|
||||
|
||||
## Customizing Checks
|
||||
|
||||
If your application needs a longer period to boot up - perhaps to load data into memory, or because of slow boot time - you may also use dokku's `checks` functionality to more precisely check whether an application can serve traffic or not.
|
||||
|
||||
@@ -1,30 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " help checks:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
case "$1" in
|
||||
help | checks:help)
|
||||
help_content_func () {
|
||||
declare desc="return checks plugin help content"
|
||||
cat<<help_content
|
||||
checks <app>, Show zero-downtime status
|
||||
checks:disable <app> [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments***
|
||||
checks:enable <app> [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list)
|
||||
checks:run <app> [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
checks:skip <app> [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
help_content
|
||||
}
|
||||
|
||||
if [[ $1 = "checks:help" ]] ; then
|
||||
echo -e 'Usage: dokku checks[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Manage zero-downtime settings.'
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
help_content_func | sort | column -c2 -t -s,
|
||||
else
|
||||
help_content_func
|
||||
fi
|
||||
checks_help_cmd "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
32
plugins/checks/internal-functions
Executable file
32
plugins/checks/internal-functions
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
checks_help_content_func() {
|
||||
declare desc="return checks plugin help content"
|
||||
cat<<help_content
|
||||
checks <app>, [DEPRECATED] Alternative for checks:report
|
||||
checks:disable <app> [process-type(s)], Disable zero-downtime deployment for all processes (or comma-separated process-type list) ***WARNING: this will cause downtime during deployments***
|
||||
checks:enable <app> [process-type(s)], Enable zero-downtime deployment for all processes (or comma-separated process-type list)
|
||||
checks:report [<app>] [<flag>], Displays a checks report for one or more apps
|
||||
checks:run <app> [process-type(s)], Runs zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
checks:skip <app> [process-type(s)], Skip zero-downtime checks for all processes (or comma-separated process-type list)
|
||||
help_content
|
||||
}
|
||||
|
||||
checks_help_cmd() {
|
||||
if [[ $1 = "checks:help" ]] ; then
|
||||
echo -e 'Usage: dokku checks[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Manage zero-downtime settings.'
|
||||
echo ''
|
||||
echo 'Additional commands:'
|
||||
checks_help_content_func | sort | column -c2 -t -s,
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
checks_help_content_func
|
||||
else
|
||||
cat<<help_desc
|
||||
checks, Manage zero-downtime settings
|
||||
help_desc
|
||||
fi
|
||||
}
|
||||
@@ -12,6 +12,7 @@ checks_main_cmd() {
|
||||
local APPS="$1"
|
||||
fi
|
||||
|
||||
dokku_log_warn "Deprecated: Please use checks:report"
|
||||
dokku_col_log_info1_quiet "App Name" "Proctypes Disabled" "Proctypes Skipped"
|
||||
local app
|
||||
for app in $APPS; do
|
||||
|
||||
75
plugins/checks/subcommands/report
Executable file
75
plugins/checks/subcommands/report
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/checks/functions"
|
||||
|
||||
fn-checks-disabled-list() {
|
||||
declare APP="$1"
|
||||
|
||||
local DOKKU_CHECKS_DISABLED=$(config_get "$APP" DOKKU_CHECKS_DISABLED)
|
||||
DOKKU_CHECKS_DISABLED="${DOKKU_CHECKS_DISABLED:-none}"
|
||||
echo "$DOKKU_CHECKS_DISABLED"
|
||||
}
|
||||
|
||||
fn-checks-skipped-list() {
|
||||
declare APP="$1"
|
||||
|
||||
local DOKKU_CHECKS_SKIPPED=$(config_get "$APP" DOKKU_CHECKS_SKIPPED)
|
||||
DOKKU_CHECKS_SKIPPED="${DOKKU_CHECKS_SKIPPED:-none}"
|
||||
echo "$DOKKU_CHECKS_SKIPPED"
|
||||
}
|
||||
|
||||
checks_report_single_app() {
|
||||
local APP="$1"; local APP_DIR="$DOKKU_ROOT/$APP"; local INFO_FLAG="$2"
|
||||
if [[ "$INFO_FLAG" == "true" ]]; then
|
||||
INFO_FLAG=""
|
||||
fi
|
||||
verify_app_name "$APP"
|
||||
local flag_map=(
|
||||
"--checks-disabled-list: $(fn-checks-disabled-list "$APP")"
|
||||
"--checks-skipped-list: $(fn-checks-skipped-list "$APP")"
|
||||
)
|
||||
|
||||
if [[ -z "$INFO_FLAG" ]]; then
|
||||
dokku_log_info2 "$APP checks information"
|
||||
for flag in "${flag_map[@]}"; do
|
||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false; local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
value=${flag#*: }
|
||||
size="${#value}"
|
||||
if [[ "$size" -ne 0 ]]; then
|
||||
echo "$value" && match=true && value_exists=true
|
||||
else
|
||||
match=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$match" == "true" ]]; then
|
||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||
else
|
||||
dokku_log_fail "Invalid flag passed, valid flags:${valid_flags}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
checks_report_cmd() {
|
||||
declare desc="shows reports for an app"
|
||||
local cmd="checks:report"
|
||||
local INSTALLED_APPS=$(dokku_apps); local APP
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
for APP in $INSTALLED_APPS; do
|
||||
checks_report_single_app "$APP" "true"
|
||||
done
|
||||
else
|
||||
checks_report_single_app "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
checks_report_cmd "$@"
|
||||
Reference in New Issue
Block a user