mirror of https://github.com/odoo/docker.git
Fix a potential race condition with ps_isready
parent
ffe732cfc2
commit
ff7c7234d2
|
@ -4,6 +4,7 @@ import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||||
|
@ -46,12 +47,22 @@ if __name__ == '__main__':
|
||||||
logging.info(f"Host: {db_user}@{db_host}:{db_port}")
|
logging.info(f"Host: {db_user}@{db_host}:{db_port}")
|
||||||
logging.info(f"Timeout: {args.timeout} seconds")
|
logging.info(f"Timeout: {args.timeout} seconds")
|
||||||
|
|
||||||
status, exit_code = check_postgres_status(
|
start_time = time.time()
|
||||||
host=db_host,
|
|
||||||
port=db_port,
|
status, exit_code = "", 0
|
||||||
user=db_user,
|
|
||||||
timeout=args.timeout
|
while time.time() < start_time + args.timeout:
|
||||||
)
|
status, exit_code = check_postgres_status(
|
||||||
|
host=db_host,
|
||||||
|
port=db_port,
|
||||||
|
user=db_user,
|
||||||
|
timeout=args.timeout
|
||||||
|
)
|
||||||
|
|
||||||
|
if exit_code == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
if exit_code != 0:
|
if exit_code != 0:
|
||||||
raise DatabaseConnectionError(f"Unable to connect to the database. Exit code: {exit_code} - Message: {status}")
|
raise DatabaseConnectionError(f"Unable to connect to the database. Exit code: {exit_code} - Message: {status}")
|
||||||
|
|
Loading…
Reference in New Issue