wait for db to be ready in order to migrate

This commit is contained in:
hackerESQ
2024-12-16 21:54:59 -06:00
parent f85f0f19b9
commit 643bbe3af2
+14 -1
View File
@@ -35,7 +35,20 @@ echo "====================== Installing NPM dependencies and building frontend..
/usr/bin/npm run build
echo "====================== Running migrations... ====================== "
/usr/local/bin/php artisan migrate --force
run_migrations() {
/usr/local/bin/php artisan migrate --force
}
RETRIES=30
DELAY=5
until run_migrations; do
RETRIES=$((RETRIES-1))
if [ $RETRIES -le 0 ]; then
echo "Database is not ready after multiple attempts. Exiting..."
exit 1
fi
echo "Waiting for database to be ready... retrying in $DELAY seconds."
sleep $DELAY
done
echo "====================== Spinning up Supervisor daemon... ====================== "
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf