Spaces:
Runtime error
Runtime error
| set -e | |
| echo "Initializing Environment..." | |
| # التحقق من وجود المسارات في PATH | |
| echo "Current PATH: $PATH" | |
| # 1. تهيئة قاعدة بيانات PostgreSQL في مجلد المستخدم node | |
| if [ ! -d "$PGDATA" ]; then | |
| echo "Creating PostgreSQL data directory..." | |
| # استخدام المسار الكامل كاحتياط إذا فشل PATH | |
| initdb -D $PGDATA || /usr/lib/postgresql/*/bin/initdb -D $PGDATA | |
| fi | |
| # 2. تشغيل PostgreSQL | |
| echo "Starting PostgreSQL..." | |
| pg_ctl -D $PGDATA -l /home/node/pg_log start || /usr/lib/postgresql/*/bin/pg_ctl -D $PGDATA -l /home/node/pg_log start | |
| # 3. تشغيل Redis | |
| echo "Starting Redis..." | |
| redis-server --daemonize yes --port 6379 | |
| # 4. إعداد قاعدة البيانات والمستخدم | |
| echo "Configuring Database..." | |
| # محاولة تشغيل psql باستخدام PATH أو المسار الكامل | |
| (psql -d postgres -c "CREATE USER alk_user WITH PASSWORD 'alk_pass';" || /usr/lib/postgresql/*/bin/psql -d postgres -c "CREATE USER alk_user WITH PASSWORD 'alk_pass';") || true | |
| (psql -d postgres -c "CREATE DATABASE affiliate_launch_kit OWNER alk_user;" || /usr/lib/postgresql/*/bin/psql -d postgres -c "CREATE DATABASE affiliate_launch_kit OWNER alk_user;") || true | |
| (psql -d affiliate_launch_kit -c "GRANT ALL ON SCHEMA public TO alk_user;" || /usr/lib/postgresql/*/bin/psql -d affiliate_launch_kit -c "GRANT ALL ON SCHEMA public TO alk_user;") || true | |
| # 5. تشغيل الهجرات والبيانات الأولية | |
| echo "Running Migrations..." | |
| cd /app/backend | |
| npx typeorm-ts-node-commonjs -d src/database/data-source.ts migration:run | |
| echo "Seeding Database..." | |
| npx ts-node src/database/seed/index.ts | |
| echo "Database Ready. Starting Supervisor..." | |
| exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf | |