Skip to content

Commit 4194f1e

Browse files
authored
Close connection in postgres_ready() (baserow#4605)
1 parent 869e637 commit 4194f1e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

backend/docker/docker-entrypoint.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,29 @@ DATABASE_PASSWORD=os.getenv('DATABASE_PASSWORD')
6969
DATABASE_OPTIONS=os.getenv('DATABASE_OPTIONS')
7070
try:
7171
options = json.loads(DATABASE_OPTIONS or "{}")
72-
psycopg.connect(
72+
conn = psycopg.connect(
7373
dbname=DATABASE_NAME,
7474
user=DATABASE_USER,
7575
password=DATABASE_PASSWORD,
7676
host=DATABASE_HOST,
7777
port=DATABASE_PORT,
7878
**options
7979
)
80+
conn.close()
8081
except Exception as e:
8182
print(f"Error: Failed to connect to the postgresql database at {DATABASE_HOST}")
8283
print("Please see the error below for more details:")
8384
print(e)
8485
print("Trying again without any DATABASE_OPTIONS:")
8586
try:
86-
psycopg.connect(
87+
conn = psycopg.connect(
8788
dbname=DATABASE_NAME,
8889
user=DATABASE_USER,
8990
password=DATABASE_PASSWORD,
9091
host=DATABASE_HOST,
9192
port=DATABASE_PORT,
9293
)
94+
conn.close()
9395
except Exception as e:
9496
print(f"Error: Failed to connect to the postgresql database at {DATABASE_HOST} without the {DATABASE_OPTIONS}")
9597
print("Please see the error below for more details:")
@@ -109,9 +111,10 @@ except ImportError:
109111
import os
110112
DATABASE_URL=os.getenv('DATABASE_URL')
111113
try:
112-
psycopg.connect(
114+
conn = psycopg.connect(
113115
DATABASE_URL
114116
)
117+
conn.close()
115118
except psycopg.OperationalError as e:
116119
print(f"Error: Failed to connect to the postgresql database at {DATABASE_URL}")
117120
print("Please see the error below for more details:")

0 commit comments

Comments
 (0)