andrewrreed HF staff commited on
Commit
fd3f2e6
·
1 Parent(s): de5b0e9

cleanup stale PIDs and point to correct socket directory

Browse files
Files changed (1) hide show
  1. docker-entrypoint-wrapper.sh +13 -4
docker-entrypoint-wrapper.sh CHANGED
@@ -20,13 +20,22 @@ fi
20
 
21
  # Start PostgreSQL with the persistent directories
22
  echo "Starting PostgreSQL..."
 
 
 
 
 
 
 
 
 
23
  pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
24
 
25
- # Create database and roles
26
  echo "Creating database and roles..."
27
- createuser -s postgres || true
28
- createuser -s node || true
29
- createdb postgres || true
30
 
31
  # Wait for PostgreSQL to be ready
32
  echo "Waiting for PostgreSQL to be ready..."
 
20
 
21
  # Start PostgreSQL with the persistent directories
22
  echo "Starting PostgreSQL..."
23
+ # First, check if there's a postmaster.pid file and remove it if the process isn't running
24
+ if [ -f "/data/postgresql/data/postmaster.pid" ]; then
25
+ pid=$(cat /data/postgresql/data/postmaster.pid | head -1)
26
+ if ! kill -0 "$pid" 2>/dev/null; then
27
+ echo "Removing stale PID file..."
28
+ rm /data/postgresql/data/postmaster.pid
29
+ fi
30
+ fi
31
+
32
  pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
33
 
34
+ # Create database and roles - specify the host directory for the socket
35
  echo "Creating database and roles..."
36
+ createuser -h /data/postgresql/run -s postgres || true
37
+ createuser -h /data/postgresql/run -s node || true
38
+ createdb -h /data/postgresql/run postgres || true
39
 
40
  # Wait for PostgreSQL to be ready
41
  echo "Waiting for PostgreSQL to be ready..."