From 9b806b53f3b02f3461507275aed8d94b5e8ccf04 Mon Sep 17 00:00:00 2001 From: Shivaraj B H Date: Wed, 31 Jan 2024 18:47:52 +0530 Subject: [PATCH] postgres: always create socketDir during init if not already present (#88) If the socketDir is in tmpfs, or if it is deleted by some other process, we would want the socketDir to be created, if not already present, on restarts. --- nix/postgres/setup-script.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nix/postgres/setup-script.nix b/nix/postgres/setup-script.nix index 9492800..e1a4e8d 100644 --- a/nix/postgres/setup-script.nix +++ b/nix/postgres/setup-script.nix @@ -94,13 +94,19 @@ in fi # Setup config + echo "Setting up postgresql.conf" cp ${configFile} "$PGDATA/postgresql.conf" + # Create socketDir if it doesn't exist + if [ ! -d "${config.socketDir}" ]; then + echo "Creating socket directory" + mkdir -p "${config.socketDir}" + fi if [[ "$POSTGRES_RUN_INITIAL_SCRIPT" = "true" ]]; then echo echo "PostgreSQL is setting up the initial database." echo - PGHOST=$(mkdir -p "${config.socketDir}" && mktemp -d "$(readlink -f "${config.socketDir}")/pg-init-XXXXXX") + PGHOST=$(mktemp -d "$(readlink -f "${config.socketDir}")/pg-init-XXXXXX") export PGHOST function remove_tmp_pg_init_sock_dir() {