Commit ed031242 authored by Boxiang Sun's avatar Boxiang Sun

peertube: test fixup

parent afdfd53c
Pipeline #25188 failed with stage
in 0 seconds
......@@ -26,7 +26,7 @@ md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-service]
filename = template-peertube-service.sh.in
md5sum = 8e01664a59ac8c148075a87aabd04fef
md5sum = f4098a814c051c8636fe0c98fe74ac0c
[template-peertube-yaml]
filename = template-peertube.yaml.in
......@@ -34,7 +34,7 @@ md5sum = e761995c4c18efc4a199f11dc8fde039
[template-nginx-configuration]
filename = template-nginx.cfg.in
md5sum = 408919e5c506e9ac3e2678fd3143b2e2
md5sum = a2c0d6e873370d64de707f668a3d40e3
[template-dcron-service]
filename = template-dcron-service.sh.in
......@@ -54,4 +54,4 @@ md5sum = e50daa16a2c1866997933981bed45271
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
md5sum = 656b170ed264b749415f1d31a8c770b1
md5sum = b4f2460cb1acb256b32442034aec1cfd
......@@ -277,7 +277,6 @@ server {
# try_files $uri @api;
# }
ssl on;
ssl_certificate $${nginx-configuration:ssl_crt};
ssl_certificate_key $${nginx-configuration:ssl_key};
......
......@@ -39,36 +39,29 @@ if [ -e "$pid_file" ]; then
fi
echo "Starting postgresql..."
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} &
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory} -h $${postgresql:ipv4} -p $${postgresql:port} &
postgresql_pid=$!
trap "kill $postgresql_pid" EXIT TERM INT
pgwait=60
while ! [ -e "$pid_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "Can not create pid_file"
echo "pid_file not exist; will retry $tpgwait times..." 1>&2
sleep 1
done
# If postgres has stopped, abort
if ! [ -d /proc/$postgresql_pid ]; then
echo "postgresql exited, aborting."
exit 1
fi
echo "Parsing postgresql conf..."
postgresql_conf_file=$${postgresql:pgdata-directory}/postgresql.conf
tpgwait=60
while ! [ -e "$postgresql_conf_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "Postgresql conf file does not exist."
echo "Postgresql conf file does not exist; will retry $tpgwait times..." 1>&2
sleep 1
done
echo "Get the postgresql port number..."
port=$(awk '/^port/{print $3}' $postgresql_conf_file)
echo $port
# run psql
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
-p $port \
PGPASSWORD=$${postgresql:password} $${postgresql:bin}/psql \
-h $${postgresql:ipv4} \
-p $${postgresql:port} \
-U $${postgresql:superuser} \
-d $${postgresql:dbname} \
"$@"
......@@ -80,10 +73,6 @@ echo "Ready to check postgresql is running..."
# ( first quering PG several times waiting a bit till postgresql is started and ready )
tpgwait=60
while true; do
pgtables="$(psql -c '\d' 2>&1)"
ls -al $${postgresql:pgdata-directory}
echo $(cat $${postgresql:pgdata-directory}/pg_hba.conf)
echo $pgtables
pgtables="$(psql -c '\d' 2>&1)" && break
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pg query problem"
......@@ -105,7 +94,8 @@ fi
echo "Postgresql is running, ready to restore"
# Restore the database
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -p $port -e -c -C -d postgres $${peertube-backup-script:backup-file} || {
# Use -d to connect to the default 'postgres' database to allow us to restore the $${postgresql:dbname}
PGPASSWORD=$${postgresql:password} $${postgresql:bin}/pg_restore -h $${postgresql:ipv4} -p $${postgresql:port} -U $${postgresql:superuser} -e -c -C -d postgres $${peertube-backup-script:backup-file} || {
RESTORE_EXIT_CODE=$?
echo 'Backup restoration failed.'
exit $RESTORE_EXIT_CODE
......
......@@ -10,7 +10,8 @@ die() {
# run psql on gitlab db
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
-h $${postgresql:ipv4} \
-p $${postgresql:port} \
-U $${postgresql:superuser} \
-d $${postgresql:dbname} \
"$@"
......
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