#!/bin/bash set -Eeuo pipefail # ============================================================================= # TerManager2 — queue worker entrypoint # # Deliberately does NOT migrate or seed: the app container owns schema changes. # Two containers racing on `artisan migrate` is how you get a half-applied # schema. This one only waits for its dependencies and starts working. # ============================================================================= warn() { echo "[!] $*" >&2; } # APP_KEY must match the app container or encrypted payloads won't decrypt. KEY_FILE="/var/www/html/storage/app/.app_key" if [ -z "${APP_KEY:-}" ] && [ -s "$KEY_FILE" ]; then APP_KEY="$(cat "$KEY_FILE")" export APP_KEY fi echo "[*] Queue worker waiting for database and redis..." for _ in $(seq 1 60); do if nc -z "${DB_HOST:-mariadb}" "${DB_PORT:-3306}" \ && nc -z "${REDIS_HOST:-redis}" "${REDIS_PORT:-6379}"; then echo "[✓] Dependencies reachable." break fi sleep 2 done # Wait for the app container to finish migrating before consuming jobs, so a # job doesn't hit a table that doesn't exist yet. for _ in $(seq 1 60); do if php artisan migrate:status --no-interaction >/dev/null 2>&1; then break fi sleep 2 done exec "$@"