Solved rate limitation bug

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-17 00:03:12 +01:00
parent e94bcc3049
commit efd1b5775e

View File

@ -10,10 +10,17 @@ services:
ports: ports:
- "127.0.0.1:{{http_port}}:80" - "127.0.0.1:{{http_port}}:80"
healthcheck: healthcheck:
# This health check ensures the test email is sent only once to prevent
# hitting SMTP rate limits due to multiple health check executions.
# The logic checks for a temporary file (/tmp/email_sent) to determine
# if the email has already been sent. If the file exists, the email
# is skipped, but the health check continues by verifying the HTTP service.
# Refer to the conversation with ChatGPT (https://chatgpt.com/share/67898c3f-2c1c-800f-861c-47dcbe109135)
# on January 16, 2025, for the background behind this complexity.
test: test:
[ [
"CMD-SHELL", "CMD-SHELL",
"(echo 'Subject: testmessage from {{domain}}\n\nSUCCESSFULL' | msmtp -t {{test_email}} && curl -f http://127.0.0.1:80) || exit 1" "(if [ ! -f /tmp/email_sent ]; then echo 'Subject: testmessage from {{domain}}\n\nSUCCESSFULL' | msmtp -t {{test_email}} && touch /tmp/email_sent; fi && curl -f http://127.0.0.1:80) || exit 1"
] ]
interval: 1m interval: 1m
timeout: 10s timeout: 10s