This commit is contained in:
Andras Bacsai
2023-04-24 13:25:02 +02:00
parent 9d6c93768d
commit 570461a45f
8 changed files with 358 additions and 157 deletions

View File

@@ -3,49 +3,42 @@
# Inspired on https://github.com/adriancooney/Taskfile
#
# Install an alias, to be able to simply execute `run`
# echo 'alias run=./run' >> ~/.aliases
# echo 'alias run=./scripts/run' >> ~/.aliases
#
# Define Docker Compose command prefix...
set -e
docker compose &> /dev/null
docker compose &>/dev/null
if [ $? == 0 ]; then
DOCKER_COMPOSE="docker compose"
else
DOCKER_COMPOSE="docker-compose"
fi
SAIL=./vendor/bin/sail
export WWWUSER=${WWWUSER:-$UID}
export WWWGROUP=${WWWGROUP:-$(id -g)}
function help {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | cat -n
}
function queue {
bash vendor/bin/spin exec -u webuser coolify php artisan queue:listen
}
function reset-db {
bash vendor/bin/spin exec -u webuser coolify php artisan migrate:fresh --seed
}
function coolify {g
bash vendor/bin/spin exec -u webuser coolify bash
}
function coolify-root {
bash vendor/bin/spin exec coolify bash
}
function vite {
bash vendor/bin/spin exec vite bash
}
function default {
help
}
function wait_db {
TRIES=0
MAX_TRIES=15
WAIT=4
until $DOCKER_COMPOSE exec postgres bash -c "psql -U coolify -d coolify -t -q -c \"SELECT datname FROM pg_database;\" " | grep coolify
do
((TRIES++))
if [ $TRIES -gt $MAX_TRIES ]; then
echo "Database is not ready after $MAX_TRIES tries. Exiting."
exit 1
fi
echo "Database is not ready yet. Attempt $TRIES/$MAX_TRIES. Waiting $WAIT seconds before next try..."
sleep $WAIT
done
}
TIMEFORMAT="Task completed in %3lR"
time "${@:-default}"