Initialize the API and add managed app banners.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "Node: $(node -v)"
|
||||
echo "OpenSSL: $(openssl version 2>/dev/null || echo missing)"
|
||||
|
||||
# فقط host را لاگ کن تا سکرت لو نرود
|
||||
DB_HOST=$(printf '%s' "$DATABASE_URL" | sed -n 's|.*@\([^:/]*\).*|\1|p')
|
||||
echo "DATABASE_URL host: ${DB_HOST:-unknown}"
|
||||
|
||||
if [ ! -x ./node_modules/.bin/prisma ] && [ ! -f ./node_modules/prisma/build/index.js ]; then
|
||||
echo "ERROR: prisma در node_modules نیست. روی سرور بزن:"
|
||||
echo " npm install prisma --no-audit --no-fund --registry=https://registry.npmmirror.com"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -x ./node_modules/.bin/prisma ]; then
|
||||
PRISMA="./node_modules/.bin/prisma"
|
||||
else
|
||||
PRISMA="node ./node_modules/prisma/build/index.js"
|
||||
fi
|
||||
|
||||
echo "Waiting for database & applying migrations..."
|
||||
i=0
|
||||
until $PRISMA migrate deploy; do
|
||||
i=$((i + 1))
|
||||
if [ "$i" -ge 30 ]; then
|
||||
echo "Database/migrate failed after 30 attempts"
|
||||
exit 1
|
||||
fi
|
||||
echo "Retry $i..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ "${RUN_SEED:-false}" = "true" ]; then
|
||||
echo "Seeding database..."
|
||||
$PRISMA db seed || true
|
||||
fi
|
||||
|
||||
echo "Starting API on port ${PORT:-3000}..."
|
||||
exec node dist/main.js
|
||||
Reference in New Issue
Block a user