Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
caddy-lb-policy-switch: Fix variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kreatoo committed Jun 25, 2024
1 parent 5b4ad8b commit 29af960
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions caddy/caddy-lb-policy-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ function main() {
if [[ "$LOOP_ORDER" == "SERVERS" ]]; then
bad_urls=()
slept_for=0
start="$(date +%s)"
start_func="$(date +%s)"
for URL_TO_FIND in "${CADDY_SERVERS[@]}"; do
for URL_UP in "${CADDY_API_URLS_NEW[@]}"; do
URL="${URL_UP#*@}"
Expand All @@ -333,7 +333,7 @@ function main() {
sleep "${LB_POLICY_CHANGE_SLEEP:-1}"
slept_for=$((slept_for+LB_POLICY_CHANGE_SLEEP))
done
end="$(date +%s)"
end_func="$(date +%s)"

CADDY_SERVERS_WO_BAD=("${CADDY_SERVERS[@]}")

Expand All @@ -346,7 +346,7 @@ function main() {
CADDY_SERVERS_WO_BAD_HUMANREADABLE="${CADDY_SERVERS_WO_BAD[*]// /, }"
bad_urls_humanreadable="${bad_urls[*]// /, }"

alarm "$CADDY_SERVERS_WO_BAD_HUMANREADABLE switched to upstream $1 in $((end-start)) seconds, slept for $slept_for seconds"
alarm "$CADDY_SERVERS_WO_BAD_HUMANREADABLE switched to upstream $1 in $((end_func-start_func)) seconds, slept for $slept_for seconds"
alarm "$bad_urls_humanreadable failed to switch upstreams to $1"
else
for URL_UP in "${CADDY_API_URLS_NEW[@]}"; do
Expand All @@ -355,9 +355,7 @@ function main() {
for URL_TO_FIND in "${CADDY_SERVERS[@]}"; do
echo '---------------------------------'
echo "Checking '$URL_TO_FIND' on '$URL'"
start="$(date +%s)"
identify_request "$1" "$2"
end="$(date +%s)"
sleep "${LB_POLICY_CHANGE_SLEEP:-1}"
echo '---------------------------------'
done
Expand Down

0 comments on commit 29af960

Please sign in to comment.