File size: 1,921 Bytes
79becd2 6ff9480 94f1533 79becd2 6ff9480 79becd2 94f1533 de5b0e9 94f1533 77a2880 94f1533 5266caf 79becd2 a603a7e fd3f2e6 94f1533 79becd2 0a550c0 5266caf 0a550c0 79becd2 94f1533 5266caf 79becd2 5266caf 79becd2 94f1533 |
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 41 42 43 44 45 46 47 48 49 50 |
#!/bin/sh
# Create necessary directories in the persistent /data volume
echo "Creating necessary directories in the persistent /data volume..."
mkdir -p /data/postgresql/data /data/postgresql/run
chmod 0700 /data/postgresql/data
chmod 0755 /data/postgresql/run
# Initialize PostgreSQL if not already initialized
echo "Initializing PostgreSQL if not already initialized..."
if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then
# Initialize database
echo "Initializing database..."
initdb -D /data/postgresql/data
# Modify pg_hba.conf to allow local connections
echo "local all all trust" > /data/postgresql/data/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf
echo "host all all 0.0.0.0/0 trust" >> /data/postgresql/data/pg_hba.conf
fi
# Start PostgreSQL with the persistent directories
echo "Starting PostgreSQL..."
# First, check if there's a postmaster.pid file and remove it if the process isn't running
if [ -f "/data/postgresql/data/postmaster.pid" ]; then
pid=$(cat /data/postgresql/data/postmaster.pid | head -1)
if ! kill -0 "$pid" 2>/dev/null; then
echo "Removing stale PID file..."
rm /data/postgresql/data/postmaster.pid
fi
fi
pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
# Create the 'node' database if it doesn't exist
echo "Creating 'node' database if it doesn't exist..."
createdb -h localhost node || true
# Wait for PostgreSQL to be ready
echo "Waiting for PostgreSQL to be ready..."
until pg_isready -h localhost; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
# Update DATABASE_URL to use TCP connection instead of Unix socket
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/node"
# Run the original entrypoint script
./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000 |