meltedchoco commited on
Commit
32994cc
Β·
verified Β·
1 Parent(s): aa7f8c3

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +7 -1
entrypoint.sh CHANGED
@@ -1,12 +1,18 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
- # Use environment variables if they exist, otherwise fallback to /tmp
5
  PGDATA="${PGDATA:-/data/postgres}"
6
  PGHOST="${PGHOST:-/tmp}"
7
  PG_PORT="${PG_PORT:-5432}"
8
  SEKAI_DB_URL="postgresql://sekai:sekai@/sekai?host=${PGHOST}&port=${PG_PORT}"
9
 
 
 
 
 
 
 
 
10
  # ── Initialize Postgres if needed ────────────────────────────────────
11
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
12
  echo "Initializing PostgreSQL database in ${PGDATA}..."
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
 
4
  PGDATA="${PGDATA:-/data/postgres}"
5
  PGHOST="${PGHOST:-/tmp}"
6
  PG_PORT="${PG_PORT:-5432}"
7
  SEKAI_DB_URL="postgresql://sekai:sekai@/sekai?host=${PGHOST}&port=${PG_PORT}"
8
 
9
+ # ── Self-Healing: Check for corrupted state ──────────────────────────
10
+ # If the directory exists but is missing critical Postgres folders, wipe it.
11
+ if [ -d "${PGDATA}" ] && [ ! -d "${PGDATA}/pg_notify" ]; then
12
+ echo "Detected corrupted PostgreSQL data (missing pg_notify). Wiping for a fresh start..."
13
+ rm -rf "${PGDATA:?}"/*
14
+ fi
15
+
16
  # ── Initialize Postgres if needed ────────────────────────────────────
17
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
18
  echo "Initializing PostgreSQL database in ${PGDATA}..."