From c8592597f86c5275639ff4c45f1c73e44fe60a6e Mon Sep 17 00:00:00 2001 From: cawcenter Date: Sun, 14 Dec 2025 15:24:50 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20SAFETY:=20Make=20SQL=20?= =?UTF-8?q?schema=20non-fatal=20with=20timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added 2-minute timeout to psql execution - Schema failures no longer crash Directus startup - Directus can start with empty schema if needed - Prevents infinite hangs on large SQL files --- start.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/start.sh b/start.sh index ea3b05c..afe82fa 100755 --- a/start.sh +++ b/start.sh @@ -60,15 +60,19 @@ fi echo "đŸ“Ļ Bootstrapping Directus..." npx directus bootstrap -# === Apply Schema from Code === +# === Apply Schema from Code (NON-FATAL - Directus can start without it) === if [ -f "/directus/schema.yaml" ]; then echo "🔄 Applying schema from schema.yaml..." - npx directus schema apply /directus/schema.yaml --yes + npx directus schema apply /directus/schema.yaml --yes || echo "âš ī¸ schema.yaml apply failed, continuing anyway" echo "✅ Schema applied from code" elif [ -f "/directus/complete_schema.sql" ]; then echo "🔄 Applying schema from complete_schema.sql..." - PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_DATABASE" < /directus/complete_schema.sql - echo "✅ SQL schema applied" + # Run in background with timeout to prevent hanging + timeout 120 sh -c 'PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_DATABASE" < /directus/complete_schema.sql' || { + echo "âš ī¸ SQL schema apply failed or timed out (2 min), continuing anyway" + echo "âš ī¸ You may need to run the schema manually later" + } + echo "✅ SQL schema step complete" else echo "âš ī¸ No schema.yaml or complete_schema.sql found" echo "â„šī¸ Directus will start with empty schema"