Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos
Commits
2efb2234
Commit
2efb2234
authored
Dec 01, 2022
by
Boxiang Sun
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peertube: Empty import script
parent
3adfa54d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
112 deletions
+1
-112
software/peertube/buildout.hash.cfg
software/peertube/buildout.hash.cfg
+1
-1
software/peertube/template-peertube-restore.sh.in
software/peertube/template-peertube-restore.sh.in
+0
-111
No files found.
software/peertube/buildout.hash.cfg
View file @
2efb2234
...
@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
...
@@ -54,4 +54,4 @@ md5sum = 58d1a4fe246169dea94d7d243b4bac9e
[template-peertube-restore-script]
[template-peertube-restore-script]
filename = template-peertube-restore.sh.in
filename = template-peertube-restore.sh.in
md5sum =
c6971b7b2c503085abecd1999039a8f2
md5sum =
d41d8cd98f00b204e9800998ecf8427e
software/peertube/template-peertube-restore.sh.in
View file @
2efb2234
#!${dash-output:dash}
# DO NOT RUN THIS SCRIPT ON PRODUCTION INSTANCE
# OR POSTGRESQL DATA WILL BE ERASED.
# This script will import the dump of the postgresql database to the real
# database. It is launched by the clone (importer) instance of theia
# in the end of the import script.
# Depending on the output, it will create a file containing
# the status of the restoration (success or failure)
die() {
echo "$*" 1>&2
exit 1
}
pg_version=$${postgresql:pgdata-directory}/PG_VERSION
echo "Check postgresql data directory is ready"
tpgwait=60
while ! [ -e "$pg_version" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "PGdata directory not ready"
echo "I: PGdata directory is not ready (yet ?); will retry $tpgwait times..." 1>&2
sleep 1
done
echo "Postgresql data directory is ready"
# 2. Make sure the postgresql process is not running.
# Quote from the postgresql doc:
# > While the server is running, its PID is stored in the file postmaster.pid in the data directory.
# https://www.postgresql.org/docs/current/server-start.html
# which means if the postmaster.pid exist, then the postgresql is running.
pid_file=$${postgresql:pgdata-directory}/postmaster.pid
if [ -e "$pid_file" ]; then
echo "Postgresql is running, this should not happened, aborting."
else
echo "Starting postgresql..."
$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}
fi
tpgwait=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
# run psql
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
-U $${postgresql:superuser} \
-d $${postgresql:dbname} \
"$@"
}
echo "Ready to check postgresql is running..."
# initial db setup
# ( first quering PG several times waiting a bit till postgresql is started and ready )
tpgwait=10
while true; do
pgtables="$(psql -c '\d' 2>&1)" && break
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pg query problem"
echo "I: PostgreSQL is not ready (yet ?); will retry $tpgwait times..." 1>&2
sleep 1
done
echo "I: PostgreSQL ready." 1>&2
# sleep 5
echo "Check postgresql is running again"
# Check the postgresql is running, if postgresql has stopped, abort
if ! [ -e "$pid_file" ]; then
echo "postgresql exited, aborting."
exit 1
fi
echo "Postgresql is running, ready to restore"
# Restore the database
$${postgresql:bin}/pg_restore -h $${postgresql:pgdata-directory} -U peertube -e -c -C -d postgres $${directory:srv}/backup/peertube_prod-dump.db
echo "Postgresql restore finished"
pg_restore_pid=$!
echo $pg_restore_pid
wait $pg_restore_pid
echo "Backup restoration successfully completed."
# The database process should be stopped to allow
#"slapos node instance" to starts the real postgresql service
if [ -e "$pid_file" ]; then
echo "Stoping postgresql..."
pkill -9 -f "$${postgresql:bin}/postgres -D $${postgresql:pgdata-directory}"
fi
tpgwait=60
while [ -e "$pid_file" ]; do
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "Pid file always exist"
echo "I: Pid file still exist; will retry $tpgwait times..." 1>&2
sleep 1
done
echo "Postgresql process killed"
Romain Courteaud
@romain
mentioned in commit
160d4201
·
Dec 02, 2022
mentioned in commit
160d4201
mentioned in commit 160d4201f8441d86825cfb966cc5c53217ca41d2
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment