feat: add the ability to set the haproxy log level

This commit is contained in:
Jose Diaz-Gonzalez
2022-11-06 00:26:48 -04:00
parent 8bd4f66bec
commit fd09beaf48
5 changed files with 23 additions and 4 deletions

View File

@@ -101,6 +101,16 @@ dokku haproxy:logs --tail --num 10
The above command will show logs continually from the vector container, with an initial history of 10 log lines
### Changing the Haproxy log level
Haproxy log output is set to `ERROR` by default. It may be changed by setting the `log-level` property with the `--global` flag:
```shell
dokku haproxy:set --global log-level DEBUG
```
After modifying, the Haproxy container will need to be restarted.
## Displaying Haproxy reports for an app
You can get a report about the app's Haproxy config using the `haproxy:report` command:

View File

@@ -36,6 +36,7 @@ cmd-haproxy-report-single() {
verify_app_name "$APP"
local flag_map=(
"--haproxy-image: $(fn-haproxy-image)"
"--haproxy-log-level: $(fn-haproxy-log-level)"
)
if [[ -z "$INFO_FLAG" ]]; then

View File

@@ -35,7 +35,8 @@ fn-haproxy-template-compose-file() {
COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE"
fi
local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-image)")
local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-image)"
HAPROXY_LOG_LEVEL="$(fn-traefik-log-level)")
sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH"
}
@@ -43,3 +44,9 @@ fn-haproxy-template-compose-file() {
fn-haproxy-image() {
fn-plugin-property-get-default "haproxy" "--global" "image" "byjg/easy-haproxy:4.2.0"
}
fn-haproxy-log-level() {
local log_level
log_level="$(fn-plugin-property-get-default "haproxy" "--global" "log-level" "ERROR")"
echo "${log_level^^}"
}

View File

@@ -9,13 +9,13 @@ cmd-haproxy-set() {
declare cmd="haproxy:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("image")
local GLOBAL_KEYS=("image")
local VALID_KEYS=("image" "log-level")
local GLOBAL_KEYS=("image" "log-level")
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
dokku_log_fail "Invalid key specified, valid keys include: image"
dokku_log_fail "Invalid key specified, valid keys include: image log-level"
fi
if ! fn-in-array "$KEY" "${GLOBAL_KEYS[@]}"; then

View File

@@ -8,6 +8,7 @@ services:
environment:
- EASYHAPROXY_DISCOVER=docker
- EASYHAPROXY_LABEL_PREFIX=haproxy
- EASYHAPROXY_LOG_LEVEL={{ $.HAPROXY_LOG_LEVEL }}
network_mode: bridge