mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
updated entrypoint script to wait for postgres
This commit is contained in:
parent
110c5c392c
commit
3afee66aaa
@ -15,8 +15,42 @@ map_uidgid() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wait_for_postgres() {
|
||||||
|
attempt_num=1
|
||||||
|
max_attempts=5
|
||||||
|
|
||||||
|
echo "Waiting for PostgreSQL to start..."
|
||||||
|
|
||||||
|
host="${PAPERLESS_DBHOST}"
|
||||||
|
|
||||||
|
while !</dev/tcp/$host/5432 ;
|
||||||
|
do
|
||||||
|
|
||||||
|
if [ $attempt_num -eq $max_attempts ]
|
||||||
|
then
|
||||||
|
echo "Unable to connect to database."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Attempt $attempt_num failed! Trying again in 5 seconds..."
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
attempt_num=$(expr "$attempt_num" + 1)
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
migrations() {
|
migrations() {
|
||||||
|
|
||||||
|
if [[ -n "${PAPERLESS_DBHOST}" ]]
|
||||||
|
then
|
||||||
|
wait_for_postgres
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
# flock is in place to prevent multiple containers from doing migrations
|
# flock is in place to prevent multiple containers from doing migrations
|
||||||
# simultaneously. This also ensures that the db is ready when the command
|
# simultaneously. This also ensures that the db is ready when the command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user