feat(image): replace wit-for-psql with pg_isready

This commit is contained in:
Janik von Rotz committed 2025-03-07 09:05:53 +01:00
1 parent 4bd258b804
commit d86050d68a
3 files changed
+3 -37

No files matched your search

-2
View File
@@ -136,8 +136,6 @@ EXPOSE 8069 8071 8072
# Set the default config file
ENV ODOO_RC=/etc/odoo/odoo.conf
COPY ./image/wait-for-psql.py /usr/local/bin/
# Set default user when running the container
USER odoo
+3 -3
View File
@@ -60,7 +60,7 @@ check_config "db_user" "$PGUSER"
check_config "db_password" "$PGPASSWORD"
entrypoint-log "Waiting for database connection."
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
pg_isready -h "$PGHOST" -p "$PGPORT"
setup-mail
@@ -74,12 +74,12 @@ case "$1" in
if [[ "$1" == "scaffold" ]] ; then
exec odoo "$@"
else
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
pg_isready -h "$PGHOST" -p "$PGPORT"
exec odoo "$@" "${DB_ARGS[@]}"
fi
;;
-*)
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
pg_isready -h "$PGHOST" -p "$PGPORT"
exec odoo "$@" "${DB_ARGS[@]}"
;;
*)
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env python3
import argparse
import psycopg2
import sys
import time
if __name__ == '__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--db_host', required=True)
arg_parser.add_argument('--db_port', required=True)
arg_parser.add_argument('--db_user', required=True)
arg_parser.add_argument('--db_password', required=True)
arg_parser.add_argument('--timeout', type=int, default=5)
args = arg_parser.parse_args()
start_time = time.time()
while (time.time() - start_time) < args.timeout:
try:
conn = psycopg2.connect(user=args.db_user, host=args.db_host, port=args.db_port, password=args.db_password, dbname='postgres')
error = ''
break
except psycopg2.OperationalError as e:
error = e
else:
conn.close()
time.sleep(1)
if error:
print("Database connection failure: %s" % error, file=sys.stderr)
sys.exit(1)