initial functionality and styling pass

This commit is contained in:
Bryan Van Deusen
2025-07-29 00:34:03 -04:00
parent 1590ca72c1
commit c67f1afc1f
1763 changed files with 876 additions and 76 deletions
+29 -15
View File
@@ -1,22 +1,36 @@
#!/bin/bash
# Wait for the database to be ready (timeout after 3 minutes)
MAX_WAIT=180 # seconds
WAIT_INTERVAL=2
WAITED=0
# Default to sqlite if not specified
DB_TYPE="${DB_TYPE:-sqlite}"
until pg_isready -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" > /dev/null 2>&1; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Timeout: Could not connect to the database at $DB_HOST:$DB_PORT within $MAX_WAIT seconds."
exit 1
fi
echo "Waiting for database at $DB_HOST:$DB_PORT... ($WAITED/$MAX_WAIT seconds)"
sleep $WAIT_INTERVAL
WAITED=$((WAITED + WAIT_INTERVAL))
done
# Wait for PostgreSQL if needed
if [ "$DB_TYPE" = "postgresql" ]; then
MAX_WAIT=180
WAIT_INTERVAL=2
WAITED=0
echo "Database type is PostgreSQL. Waiting for database to be ready..."
until pg_isready -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" > /dev/null 2>&1; do
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Timeout: Could not connect to the database at $DB_HOST:$DB_PORT within $MAX_WAIT seconds."
exit 1
fi
echo "Waiting for database at $DB_HOST:$DB_PORT... ($WAITED/$MAX_WAIT seconds)"
sleep $WAIT_INTERVAL
WAITED=$((WAITED + WAIT_INTERVAL))
done
echo "Database is ready."
else
echo "Database type is SQLite. Skipping PostgreSQL readiness check."
fi
echo "Database is ready. Applying migrations..."
# Apply migrations
echo "Applying database migrations..."
flask db upgrade
# Start periodic image import in background
echo "Starting 2h import loop"
python image_import_worker.py &
# Start the Flask app
echo "Starting Flask app..."
exec flask run --host=0.0.0.0 --port=5000
exec flask run --host=0.0.0.0 --port=5000