Files
email_reports/docker-entrypoint.sh
Frank John Begornia 3dcc7c4c6e
All checks were successful
Deploy Production Email Reports (Unified) / deploy (push) Successful in 54s
Fix crond setpgid error by running in background with tail
2026-01-02 01:47:26 +08:00

59 lines
1.3 KiB
Bash

#!/bin/sh
set -e
echo "Email Reports Container Starting..."
echo "Current time: $(date)"
echo "Timezone: $(date +%Z)"
# Verify crontab is configured
echo ""
echo "Cron schedule:"
crontab -l || echo "Warning: No crontab found"
# Create log file if it doesn't exist
touch /var/log/cron.log
chmod 666 /var/log/cron.log
# Create email log if it doesn't exist
touch /app/email.log
chmod 666 /app/email.log
# Test PHP
echo ""
echo "Testing PHP..."
php -v || { echo "PHP test failed"; exit 1; }
# Test database connectivity (optional - won't fail if not reachable)
echo ""
echo "Environment variables loaded:"
echo " DB_HOST_CREW: ${DB_HOST_CREW:-not set}"
echo " DB_HOST_MERCHBAY: ${DB_HOST_MERCHBAY:-not set}"
echo " SMTP_HOST: ${SMTP_HOST:-not set}"
# Start crond in background
echo ""
echo "Starting cron daemon..."
echo "Logs will be written to:"
echo " - Cron output: /var/log/cron.log"
echo " - Email logs: /app/email.log"
echo ""
# Start crond in background
crond -l 2
# Verify crond started
sleep 2
if ! ps aux | grep -v grep | grep -q crond; then
echo "ERROR: crond failed to start"
exit 1
fi
echo "✓ Cron daemon is running"
echo ""
echo "Container is ready. Tailing logs..."
echo "Press Ctrl+C to stop (but don't - this keeps the container alive!)"
echo ""
# Keep container alive by tailing logs
tail -f /var/log/cron.log /app/email.log