72 lines
2.2 KiB
Bash
Executable File
72 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
echo "=== SIDEL ScriptsManager Docker Entrypoint ==="
|
|
echo "Working directory: $(pwd)"
|
|
echo "User: $(whoami)"
|
|
echo "Database URL: ${DATABASE_URL:-'Not set'}"
|
|
|
|
# Activar conda environment
|
|
source /opt/conda/etc/profile.d/conda.sh
|
|
conda activate scriptsmanager
|
|
cd /app
|
|
|
|
echo "Available conda environments:"
|
|
conda env list
|
|
|
|
echo "Python path:"
|
|
which python
|
|
|
|
echo "Testing python modules:"
|
|
python -c "import flask; print(f'Flask: {flask.__version__}')"
|
|
python -c "import sqlalchemy; print(f'SQLAlchemy: {sqlalchemy.__version__}')"
|
|
|
|
# Verificar que los directorios necesarios existen
|
|
echo "Checking data directories..."
|
|
ls -la data/ instance/ logs/ || echo "Creating missing directories..."
|
|
|
|
# Database setup based on DATABASE_URL
|
|
if [[ "${DATABASE_URL}" == postgresql* ]]; then
|
|
echo "=== PostgreSQL Database Setup ==="
|
|
|
|
# Extract database connection info
|
|
DB_HOST=$(echo $DATABASE_URL | sed -n 's/.*@\([^:]*\).*/\1/p')
|
|
DB_PORT=$(echo $DATABASE_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
|
|
DB_NAME=$(echo $DATABASE_URL | sed -n 's/.*\/\([^?]*\).*/\1/p')
|
|
|
|
echo "Database Host: ${DB_HOST}"
|
|
echo "Database Port: ${DB_PORT}"
|
|
echo "Database Name: ${DB_NAME}"
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
echo "Waiting for PostgreSQL to be ready..."
|
|
|
|
# Simple wait to ensure PostgreSQL has time to start
|
|
sleep 15
|
|
echo "PostgreSQL should be ready - proceeding..."
|
|
|
|
else
|
|
echo "=== SQLite Database Setup ==="
|
|
# Asegurar que la base de datos SQLite puede ser creada
|
|
echo "Setting up SQLite database permissions..."
|
|
touch data/scriptsmanager.db || echo "Database file already exists or created"
|
|
chmod 664 data/scriptsmanager.db || true
|
|
fi
|
|
|
|
# Inicializar base de datos
|
|
echo "Initializing database schema..."
|
|
python scripts/init_db.py
|
|
|
|
# Verificar entornos conda
|
|
echo "ScriptsManager environment packages:"
|
|
conda list -n scriptsmanager | grep -E "(flask|sqlalchemy|psycopg2)" || true
|
|
|
|
echo "TSNet environment packages:"
|
|
conda list -n tsnet | grep -E "(tsnet|numpy|matplotlib)" || true
|
|
|
|
# Database health check
|
|
echo "Performing database health check..."
|
|
echo "Skipping health check for now - starting application"
|
|
|
|
echo "=== SIDEL ScriptsManager Ready ==="
|
|
exec "$@" |