Spaces:
Runtime error
Runtime error
File size: 1,375 Bytes
c01f819 290832d c01f819 290832d b70cab0 290832d b70cab0 290832d b70cab0 290832d c01f819 b70cab0 290832d b70cab0 c01f819 706cc74 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/usr/bin/env bash
set -e
# ★ /data と /data/exports を必ず作成
mkdir -p /data /data/exports
start_postgres() {
echo "[init] starting internal postgres..."
mkdir -p /data/postgres
chown -R postgres:postgres /data/postgres
PG_BIN=$(pg_config --bindir 2>/dev/null || echo "/usr/lib/postgresql/15/bin")
su - postgres -s /bin/bash -c "$PG_BIN/initdb -D /data/postgres" || true
su - postgres -s /bin/bash -c "$PG_BIN/pg_ctl -D /data/postgres -l /data/postgres/logfile start"
sleep 2
su - postgres -s /bin/bash -c "psql -tc \"SELECT 1 FROM pg_roles WHERE rolname='${POSTGRES_USER}'\" | grep -q 1 || psql -c \"CREATE USER ${POSTGRES_USER} WITH PASSWORD '${POSTGRES_PASSWORD}';\""
su - postgres -s /bin/bash -c "psql -lqt | cut -d '|' -f 1 | grep -qw ${POSTGRES_DB} || createdb -O ${POSTGRES_USER} ${POSTGRES_DB}"
echo "[ok] postgres is up"
}
echo "[entrypoint] Starting redis-server..."
/usr/bin/redis-server --save "" --appendonly no &
if [ "${USE_INTERNAL_POSTGRES}" = "true" ]; then
start_postgres
else
echo "[entrypoint] USE_INTERNAL_POSTGRES != true (using SQLite)"
fi
echo "[entrypoint] Starting celery worker..."
cd /app
celery -A app.tasks.celery_app worker --loglevel=INFO &
echo "[entrypoint] Starting uvicorn..."
python -m app.main &
echo "[entrypoint] Running init_db bootstrap..."
python /app/scripts/init_db.py || true
wait -n
|