- Implemented SvelteKit frontend with authentication callback handling. - Created demo routes and paraglide localization functionality. - Added health check and entrypoint scripts for backend services. - Established PostgreSQL and Keycloak initialization scripts with health checks. - Introduced models for database schema using SQLAlchemy. - Configured Vite and SvelteKit for development and testing environments. - Added health check script to verify service statuses and resource usage. - Created Docker entrypoint scripts for seamless service startup.
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Script de inicialización para Keycloak
|
|
# Espera a que PostgreSQL esté completamente listo antes de iniciar
|
|
|
|
echo "=========================================="
|
|
echo "Keycloak - Inicialización"
|
|
echo "=========================================="
|
|
|
|
# Función para esperar a PostgreSQL
|
|
wait_for_postgres() {
|
|
local host=$1
|
|
local port=$2
|
|
local user=$3
|
|
local db=$4
|
|
local max_attempts=60
|
|
local attempt=1
|
|
|
|
echo "Esperando a que PostgreSQL esté disponible en ${host}:${port}..."
|
|
|
|
while [ $attempt -le $max_attempts ]; do
|
|
if pg_isready -h "$host" -p "$port" -U "$user" > /dev/null 2>&1; then
|
|
# PostgreSQL acepta conexiones, verificar que la base de datos existe
|
|
if psql -h "$host" -p "$port" -U "$user" -d "$db" -c "SELECT 1" > /dev/null 2>&1; then
|
|
echo "✓ PostgreSQL está listo y la base de datos '$db' existe"
|
|
return 0
|
|
else
|
|
echo "PostgreSQL está listo pero la base de datos '$db' no existe aún... (intento $attempt/$max_attempts)"
|
|
fi
|
|
else
|
|
echo "PostgreSQL no está listo aún... (intento $attempt/$max_attempts)"
|
|
fi
|
|
|
|
attempt=$((attempt + 1))
|
|
sleep 2
|
|
done
|
|
|
|
echo "✗ ERROR: PostgreSQL no estuvo disponible después de $max_attempts intentos"
|
|
exit 1
|
|
}
|
|
|
|
# Esperar a que PostgreSQL esté listo
|
|
wait_for_postgres "${KC_DB_URL_HOST:-postgres-keycloak}" "${KC_DB_URL_PORT:-5432}" "${KC_DB_USERNAME:-postgres}" "${KC_DB_URL_DATABASE:-keycloak}"
|
|
|
|
echo "Iniciando Keycloak..."
|
|
echo "=========================================="
|
|
|
|
# Ejecutar el comando original de Keycloak
|
|
exec /opt/keycloak/bin/kc.sh "$@"
|