All checks were successful
Deploy Production Email Reports (Unified) / deploy (push) Successful in 57s
74 lines
1.7 KiB
Bash
74 lines
1.7 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 ""
|
|
|
|
# Send test emails for both brands
|
|
echo "Sending test emails to verify configuration..."
|
|
echo ""
|
|
|
|
echo "[Testing Crew Sportswear]"
|
|
BRAND=crew php /app/send_report.php
|
|
echo ""
|
|
|
|
echo "[Testing MerchBay]"
|
|
BRAND=merchbay php /app/send_report.php
|
|
echo ""
|
|
|
|
echo "✓ Test emails sent. Check graphics@crewsportswear.com inbox."
|
|
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
|