Reduce healthcheck internal while keep performance

This commit is contained in:
hellodword 2024-06-27 02:08:13 +00:00
parent a4c7fadbf4
commit 6c87c8882e
No known key found for this signature in database
GPG key ID: 094D44EBA7DBAE80
4 changed files with 12 additions and 4 deletions

View file

@ -153,6 +153,6 @@ COPY docker/healthcheck.sh docker/start.sh /
COPY --from=vault /web-vault ./web-vault
COPY --from=build /app/target/final/vaultwarden .
HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
HEALTHCHECK --interval=3s --timeout=2s CMD ["/healthcheck.sh"]
CMD ["/start.sh"]

View file

@ -196,6 +196,6 @@ COPY docker/healthcheck.sh docker/start.sh /
COPY --from=vault /web-vault ./web-vault
COPY --from=build /app/target/final/vaultwarden .
HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
HEALTHCHECK --interval=3s --timeout=2s CMD ["/healthcheck.sh"]
CMD ["/start.sh"]

View file

@ -240,6 +240,6 @@ COPY docker/healthcheck.sh docker/start.sh /
COPY --from=vault /web-vault ./web-vault
COPY --from=build /app/target/final/vaultwarden .
HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
HEALTHCHECK --interval=3s --timeout=2s CMD ["/healthcheck.sh"]
CMD ["/start.sh"]

View file

@ -1,5 +1,13 @@
#!/usr/bin/env sh
LAST_HEALTHY_FILE="/tmp/healthy"
last_check="$(cat "$LAST_HEALTHY_FILE" 2>/dev/null || echo "0")"
current_time="$(date +%s)"
if [ $((current_time - last_check)) -le 60 ]; then
exit 0
fi
# Use the value of the corresponding env var (if present),
# or a default value otherwise.
: "${DATA_FOLDER:="/data"}"
@ -62,4 +70,4 @@ if [ -n "${ROCKET_TLS}" ]; then
s='s'
fi
curl --insecure --fail --silent --show-error \
"http${s}://${addr}:${ROCKET_PORT}${base_path}/alive" || exit 1
"http${s}://${addr}:${ROCKET_PORT}${base_path}/alive" && echo "$current_time" > "$LAST_HEALTHY_FILE" || exit 1