fix: improve entrypoint.sh volume mount handling
- Add 3 second delay to wait for Easypanel volume mount - Check file size as backup (seeded DB > 1KB, empty < 1KB) - Check content table count as primary validation - Safer fallback if any check fails Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,21 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Only seed on first launch (when data.db doesn't exist or is empty)
|
# Wait for volume mount to settle (Easypanel may mount after container starts)
|
||||||
# Check if content table has any entries
|
sleep 3
|
||||||
if [ ! -f data.db ] || ! sqlite3 data.db "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
|
|
||||||
echo "Database missing or empty, running emdash init & seed..."
|
# Check if data.db exists and has content
|
||||||
pnpm exec emdash init
|
# Using file size as backup check (empty DB is ~8KB, seeded DB is much larger)
|
||||||
pnpm exec emdash seed
|
DB_SIZE=$(stat -c%s /app/data.db 2>/dev/null || stat -f%z /app/data.db 2>/dev/null || echo "0")
|
||||||
else
|
|
||||||
echo "Database exists with content, starting normally..."
|
if [ -f /app/data.db ] && [ "$DB_SIZE" -gt 1000 ]; then
|
||||||
|
# DB exists and has size > 1KB, check if it has content
|
||||||
|
if sqlite3 /app/data.db "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then
|
||||||
|
echo "Database exists with content, starting normally..."
|
||||||
|
exec node ./dist/server/entry.mjs
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Database missing, empty, or corrupted. Running emdash init & seed..."
|
||||||
|
cd /app
|
||||||
|
pnpm exec emdash init
|
||||||
|
pnpm exec emdash seed
|
||||||
exec node ./dist/server/entry.mjs
|
exec node ./dist/server/entry.mjs
|
||||||
Reference in New Issue
Block a user