schedule:work now doesnt exit immediately, add wait_for_db for queue
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 3m24s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 12m8s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Create Docker Image / Build Docker Test Image (x86_64) (push) Successful in 54s
Create Docker Image / Final Docker Test Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2024-09-24 23:21:05 +10:00
parent b665751711
commit d62cc85c97

View File

@ -31,6 +31,17 @@ function nginx_start() {
fi
}
function wait_for_db() {
# Wait for DB to be active
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1;
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
}
# Run any container setup
[ -x /sbin/init-container ] && /sbin/init-container
@ -101,13 +112,7 @@ if [ -r artisan -a -e ${php}/.env ]; then
# If DB_HOST not set, source the env file
[ -z "${DB_HOST}" -a -r .env ] && . .env
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1;
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
wait_for_db
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
fi
@ -149,6 +154,8 @@ if [ -r artisan -a -e ${php}/.env ]; then
# We'll delay starting in case the app is caching
sleep 15
wait_for_db
su www-data -s /bin/sh -c "
while true; do
php ${PHP_OPTIONS} artisan queue:${QUEUE_CMD} --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}
@ -162,7 +169,7 @@ if [ -r artisan -a -e ${php}/.env ]; then
su www-data -s /bin/sh -c "
while true; do
(php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction &)
php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction
done
"
fi