-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from factisresearch/pb/safeinit
Make sure we don't start up with an incompletely initialized database
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0 | ||
1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@@ -308,8 +308,19 @@ _main() { | ||
exec gosu postgres "$BASH_SOURCE" "$@" | ||
fi | ||
|
||
+ local initFailed="$PGDATA/INITFAILED" | ||
+ | ||
+ if [ -s "$initFailed" ]; then | ||
+ cat >&2 <<-'EOE' | ||
+ Error: Previous database initialization failed. | ||
+ EOE | ||
+ exit 1 | ||
+ fi | ||
+ | ||
# only run initialization on an empty data directory | ||
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then | ||
+ trap "mkdir $initFailed" EXIT | ||
+ | ||
docker_verify_minimum_env | ||
|
||
# check dir permissions to reduce likelihood of half-initialized database | ||
@@ -329,6 +340,8 @@ _main() { | ||
docker_temp_server_stop | ||
unset PGPASSWORD | ||
|
||
+ trap - EXIT | ||
+ | ||
cat <<-'EOM' | ||
|
||
PostgreSQL init process complete; ready for start up. |