Spaces:
Runtime error
Runtime error
| 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 | |