#!/bin/sh set -e # queue/scheduler: no composer/migrate/asset-publish here (that's entrypoint.sh, run # by app only) — just wait for app's migration to finish, then start the process. mkdir -p storage/app/public storage/framework/cache storage/framework/sessions storage/framework/views storage/logs storage/framework bootstrap/cache # Same reasoning as entrypoint.sh: this container gets replaced on every deploy # (dev and production alike), so this is a fresh boot clearing stale artifacts # left on disk (cached config, compiled views), not a running process being # told to forget in-memory code. queue:work/schedule:work themselves still # can't pick up a later code change without an actual process restart — this # only fixes what's stale on disk at boot. echo "[entrypoint] Clearing cached config/routes/views..." php artisan optimize:clear --quiet echo "[entrypoint] Caches cleared" # Universal, in both dev and production — app's entrypoint always writes this # marker after `migrate --force` completes (single app instance, so there's # exactly one writer), and queue/scheduler must never start against a database # schema that migration hasn't finished bringing up to date yet. echo "[entrypoint] Waiting for migrations to complete..." timeout=60 while [ ! -f storage/framework/migrated ] && [ "$timeout" -gt 0 ]; do sleep 1 timeout=$((timeout - 1)) done if [ ! -f storage/framework/migrated ]; then echo "[entrypoint] Timed out waiting for migrations" >&2 exit 1 fi if [ "$APP_ENV" = "production" ]; then # Same reasoning as entrypoint.sh's own production-only optimize step — # queue:work/schedule:work read config on every job/tick too, so this # avoids paying the same uncached-config cost app pays per request. echo "[entrypoint] Caching config/routes/views for production..." php artisan optimize --quiet echo "[entrypoint] Production caches built" fi exec "$@"