mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 15:28:06 +02:00
Wait for mongo, instead of a static sleep
This commit is contained in:
parent
7acd8e212e
commit
bf7f30aa2f
2 changed files with 16 additions and 6 deletions
11
bin/backup
11
bin/backup
|
@ -32,6 +32,13 @@ This file can then be consumed by the bin/restore script.
|
|||
EOF
|
||||
}
|
||||
|
||||
function wait-for-mongo () {
|
||||
while ! "$TOOLKIT_ROOT/bin/docker-compose" exec -T mongo \
|
||||
mongo --eval "db.version()" \
|
||||
> /dev/null; do echo '[mongo is not ready]' && sleep 1; done
|
||||
echo '[mongo is ready]'
|
||||
}
|
||||
|
||||
function create-tmp-dir () {
|
||||
local now
|
||||
now="$(date '+%F-%H%M%S')"
|
||||
|
@ -60,9 +67,7 @@ function dump-mongo () {
|
|||
mkdir "$mongo_tmp_dir"
|
||||
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" up -d mongo
|
||||
|
||||
# TODO: can we port over the wait-for-mongo script?
|
||||
sleep 10
|
||||
wait-for-mongo
|
||||
|
||||
# shellcheck disable=SC1004
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" exec mongo bash -lc '\
|
||||
|
|
11
bin/restore
11
bin/restore
|
@ -41,6 +41,13 @@ Examples:
|
|||
EOF
|
||||
}
|
||||
|
||||
function wait-for-mongo () {
|
||||
while ! "$TOOLKIT_ROOT/bin/docker-compose" exec -T mongo \
|
||||
mongo --eval "db.version()" \
|
||||
> /dev/null; do echo '[mongo is not ready]' && sleep 1; done
|
||||
echo '[mongo is ready]'
|
||||
}
|
||||
|
||||
function create-tmp-dir () {
|
||||
local now
|
||||
now="$(date '+%F-%H%M%S')"
|
||||
|
@ -68,11 +75,9 @@ function restore-mongo () {
|
|||
local mongo_tmp_dir="$tmp_dir/backup/mongo"
|
||||
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" up -d mongo
|
||||
wait-for-mongo
|
||||
"$TOOLKIT_ROOT/bin/docker-compose" up -d sharelatex
|
||||
|
||||
# TODO: can we port over the wait-for-mongo script?
|
||||
sleep 10
|
||||
|
||||
## Copy data into container
|
||||
docker cp \
|
||||
"$mongo_tmp_dir/dump" \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue