#!/bin/sh set -e # Source common functions . /usr/local/bin/entrypoint-common.sh echo "Starting Pixelfed Worker Container..." # CRITICAL FIX: Remove stale package discovery cache files FIRST echo "Removing stale package discovery cache files..." rm -f /var/www/pixelfed/bootstrap/cache/packages.php || true rm -f /var/www/pixelfed/bootstrap/cache/services.php || true rm -f /var/www/pixelfed/bootstrap/cache/config.php || true # Create worker-specific directories mkdir -p /var/log/supervisor # Skip database initialization - handled by init-job # Just set up basic directory structure echo "Setting up worker container..." setup_directories # Wait for database to be ready (but don't initialize) echo "Waiting for database connection..." cd /var/www/pixelfed for i in $(seq 1 12); do if php artisan migrate:status >/dev/null 2>&1; then echo "Database is ready!" break fi echo "Database not ready yet, waiting... (attempt $i/12)" sleep 5 done # Clear Laravel caches to ensure fresh service provider registration echo "Clearing Laravel caches and regenerating package discovery..." php artisan config:clear || true php artisan route:clear || true php artisan view:clear || true php artisan cache:clear || true # Remove and regenerate package discovery cache rm -f bootstrap/cache/packages.php bootstrap/cache/services.php || true php artisan package:discover --ansi || true # Clear and restart Horizon queues echo "Preparing Horizon queue system..." # Clear any existing queue data php artisan horizon:clear || true # Publish Horizon assets if needed php artisan horizon:publish || true echo "Worker container initialization complete!" echo "Starting Laravel Horizon and Scheduler..." # Execute the main command (supervisord) exec "$@"