mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-02-17 14:53:56 +00:00
Compare commits
9 Commits
master
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fcbd33ee1 | ||
|
|
c8acacb5b1 | ||
|
|
322841cbeb | ||
|
|
de3d617840 | ||
|
|
a98a5b298d | ||
|
|
4d55d037c0 | ||
|
|
bdc02ce882 | ||
|
|
d73223cd93 | ||
|
|
376ba57f35 |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user