Compare commits

...

10 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
0fcbd33ee1 Add CLAMD_STARTUP_TIMEOUT to docker-compose.yml environment
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 13:19:07 +00:00
copilot-swe-agent[bot]
c8acacb5b1 Use wall clock time for accurate elapsed time reporting
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:44:20 +00:00
copilot-swe-agent[bot]
322841cbeb Use localhost for consistency and fix timing to report 0 seconds when ready immediately
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:43:03 +00:00
copilot-swe-agent[bot]
de3d617840 Fix timing accuracy and simplify final status reporting
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:41:19 +00:00
copilot-swe-agent[bot]
a98a5b298d Refactor clamd readiness check with helper function and improve timing logic
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:39:49 +00:00
copilot-swe-agent[bot]
4d55d037c0 Fix timing accuracy and improve status messaging in clamd startup
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:38:14 +00:00
copilot-swe-agent[bot]
bdc02ce882 Make clamd startup timeout configurable and add readiness check
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:36:52 +00:00
copilot-swe-agent[bot]
d73223cd93 Add 10-minute startup grace period for clamd to fix memory limiting issue
Co-authored-by: DerLinkman <62480600+DerLinkman@users.noreply.github.com>
2025-12-11 12:35:21 +00:00
copilot-swe-agent[bot]
376ba57f35 Initial plan 2025-12-11 12:32:29 +00:00
DerLinkman
4ef65fc382 Merge pull request #6948 from mailcow/staging
2025-12
2025-12-09 13:29:15 +01:00
2 changed files with 46 additions and 0 deletions

View File

@@ -95,6 +95,51 @@ echo "$(clamd -V) is starting... please wait a moment."
nice -n10 clamd &
BACKGROUND_TASKS+=($!)
# Give clamd time to start up, especially with limited resources
# This grace period allows clamd to initialize fully before health checks begin
# Can be configured via CLAMD_STARTUP_TIMEOUT environment variable
STARTUP_GRACE_PERIOD=${CLAMD_STARTUP_TIMEOUT:-600} # Default: 10 minutes in seconds
echo "Waiting up to ${STARTUP_GRACE_PERIOD} seconds for clamd to start up..."
# Helper function to check if clamd is ready
clamd_is_ready() {
[ "$(echo "PING" | nc -w 1 localhost 3310 2>/dev/null)" = "PONG" ]
}
# Wait for clamd to be ready or until timeout
START_TIME=$(date +%s)
POLL_INTERVAL=10
CLAMD_READY=0
while true; do
CURRENT_TIME=$(date +%s)
ELAPSED=$((CURRENT_TIME - START_TIME))
# Check if clamd is responsive by attempting to connect on localhost
# clamd listens on 0.0.0.0:3310 (configured in Dockerfile)
if clamd_is_ready; then
echo "clamd is ready after ${ELAPSED} seconds"
CLAMD_READY=1
break
fi
# Check if we've exceeded the timeout
if [ ${ELAPSED} -ge ${STARTUP_GRACE_PERIOD} ]; then
break
fi
sleep ${POLL_INTERVAL}
done
# Report final status only if not already reported as ready
if [ ${CLAMD_READY} -eq 0 ]; then
if clamd_is_ready; then
echo "clamd is now ready (started during final check)"
else
echo "Warning: clamd did not respond to PING within ${STARTUP_GRACE_PERIOD} seconds - it may still be starting up"
fi
fi
while true; do
for bg_task in ${BACKGROUND_TASKS[*]}; do
if ! kill -0 ${bg_task} 1>&2; then

View File

@@ -75,6 +75,7 @@ services:
environment:
- TZ=${TZ}
- SKIP_CLAMD=${SKIP_CLAMD:-n}
- CLAMD_STARTUP_TIMEOUT=${CLAMD_STARTUP_TIMEOUT:-600}
volumes:
- ./data/conf/clamav/:/etc/clamav/:Z
- clamd-db-vol-1:/var/lib/clamav