Skip to content

Commit

Permalink
fix(postgres): Move pg_ctl stop to trap during init
Browse files Browse the repository at this point in the history
Ensuring init process from keep running because one of
`initialDatabases` or `initialScripts` failed to run
  • Loading branch information
shivaraj-bh committed Nov 4, 2024
1 parent 75c2f5a commit eb239b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nix/services/postgres/setup-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ in
}
trap 'remove_tmp_pg_init_sock_dir "$PGHOST"' EXIT
trap 'pg_ctl -D "$PGDATA" -m fast -w stop' EXIT
pg_ctl -D "$PGDATA" -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${toString config.port}"
${runInitialScript.before}
${setupInitialDatabases}
${runInitialScript.after}
pg_ctl -D "$PGDATA" -m fast -w stop
remove_tmp_pg_init_sock_dir "$PGHOST"
else
echo
echo "PostgreSQL database directory appears to contain a database; Skipping initialization"
Expand Down

0 comments on commit eb239b0

Please sign in to comment.