diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b7598e..0ac95b78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # nystudio107/craft Change Log +## 2.5.1 - 2022.03.17 +### Added + +* Run migrations / project config changes via the `run_queue.sh` script, only after the db container responds + ## 2.5.0 - 2022.03.17 -### Changed ### Added * Significantly increased startup times via a `composer_install.sh` script that only runs `composer install` at container startup time if `composer.lock` or `vendor/` is missing diff --git a/docker-config/php-prod-craft/Dockerfile b/docker-config/php-prod-craft/Dockerfile index d57f248d..66dd81a7 100755 --- a/docker-config/php-prod-craft/Dockerfile +++ b/docker-config/php-prod-craft/Dockerfile @@ -72,8 +72,4 @@ CMD chown -R www-data:www-data /var/www/project \ && \ ./composer_install.sh \ && \ - cd /var/www/project/cms \ - && \ - su-exec www-data composer craft-update \ - && \ php-fpm diff --git a/docker-config/php-prod-craft/run_queue.sh b/docker-config/php-prod-craft/run_queue.sh index 0ee174e1..49a62610 100755 --- a/docker-config/php-prod-craft/run_queue.sh +++ b/docker-config/php-prod-craft/run_queue.sh @@ -3,19 +3,22 @@ # Run Queue shell script # # This shell script runs the Craft CMS queue via `php craft queue/listen` -# It's wrapped in a "keep alive" infinite loop that restarts the command -# (after a 60 second sleep) should it exit unexpectedly for any reason +# It waits until the database container responds, then runs any pending +# migrations / project config changes via the `craft-update` Composer script, +# then runs the queue listener that listens for and runs pending queue jobs # # @author nystudio107 -# @copyright Copyright (c) 2020 nystudio107 +# @copyright Copyright (c) 2022 nystudio107 # @link https://nystudio107.com/ # @license MIT -sleep 60 -while true +# Wait until the db container responds +until eval "PGPASSWORD=$DB_PASSWORD psql -h postgres -U $DB_USER $DB_DATABASE -c 'select 1' > /dev/null 2>&1" do - cd /var/www/project/cms - su-exec www-data php craft queue/listen 10 - echo "-> craft queue/listen will retry in 60 seconds" - sleep 60 + sleep 1 done +# Run any pending migrations/project config changes +cd /var/www/project/cms +su-exec www-data composer craft-update +# Run a queue listener +su-exec www-data php craft queue/listen 10