Commit 7e999c14 authored by Kirill Smelkov's avatar Kirill Smelkov

gitlab/gitlab-unicorn-startup: Factor our psql call

We'll need to invoke psql connected to gitlab db in another place, so
before doing it let's factor out the code to call psql as connected to a
separate function.
parent 2a835e63
......@@ -9,6 +9,15 @@ die() {
exit 1
}
# run psql on gitlab db
psql() {
{{ psql_bin }} \
-h {{ pgsql['pgdata-directory'] }} \
-U {{ pgsql.superuser }} \
-d {{ pgsql.dbname }} \
"$@"
}
# 1. what to do when instance is initially setup
# see
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb
......@@ -18,12 +27,7 @@ die() {
# ( first quering PG several times waiting a bit till postgresql is started and ready )
tpgwait=5
while true; do
pgtables="$({{ psql_bin }} \
-h {{ pgsql['pgdata-directory'] }} \
-U {{ pgsql.superuser }} \
-d {{ pgsql.dbname }} \
-c '\d')" && break
pgtables="$(psql -c '\d')" && break
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pg query problem"
echo "I: PostgreSQL is not ready (yet ?); will retry $tpgwait times..." 1>&2
......
......@@ -243,7 +243,7 @@ md5sum = cdcb2036c33da547a2cf5d0515cf48ff
[gitlab-unicorn-startup.in]
<= download-file
md5sum = 14c5632182d830c03f7788c85d6f4da1
md5sum = e68d1b5376e79c5e606dce050c633d27
[gitlab.yml.in]
<= download-template
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment