Skip to content

Commit

Permalink
wait for postgres pre-start to finish, also make sure old data exists…
Browse files Browse the repository at this point in the history
… and it's not a symlink to the new data dir
  • Loading branch information
rkoster committed Dec 13, 2017
1 parent 869a00f commit 49ec7bc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jobs/migrate-postgres/templates/pre-start.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash

set -e
set -x

OLD_STORE_DIR=/var/vcap/store/postgres-9.4
NEW_STORE_DIR=/var/vcap/store/postgres

if [ ! -d ${NEW_STORE_DIR}/postgres-previous ]; then
mkdir -p ${NEW_STORE_DIR}
if [[ -d ${OLD_STORE_DIR} && ! -L ${OLD_STORE_DIR} ]]; then
# wait for postgres/bin/pre-start to creat dir
until [ -d ${NEW_STORE_DIR}/postgres-* ] && [ "$(ps aux | grep jobs/postgres/bin/pre-start | wc -l)" = "1" ]; do
sleep 1
done

rm -rf ${NEW_STORE_DIR} && mkdir -p ${NEW_STORE_DIR}
mv ${OLD_STORE_DIR} ${NEW_STORE_DIR}/postgres-unknown
ln -s ${NEW_STORE_DIR}/postgres-unknown ${OLD_STORE_DIR}
/var/vcap/jobs/postgres/bin/pre-start
Expand Down

0 comments on commit 49ec7bc

Please sign in to comment.