aboutsummaryrefslogtreecommitdiffstats
path: root/manage.py
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-09-29 04:30:17 +1000
committerGravatar scragly <[email protected]>2019-09-29 04:30:17 +1000
commitd6ad156061f175213122dc4dfbf2322a2fba7e7a (patch)
tree91618c293887e8f6971c955da83701eb40bcb6a4 /manage.py
parentRemove useless verbosity check. (diff)
Poll the database a maximum of 10 attempts before exit code 1.
Diffstat (limited to 'manage.py')
-rwxr-xr-xmanage.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/manage.py b/manage.py
index baf7333a..44435de5 100755
--- a/manage.py
+++ b/manage.py
@@ -96,7 +96,9 @@ class SiteManager:
# Attempt to connect to the database socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- while True:
+
+ attempts_left = 10
+ while attempts_left:
try:
# Ignore 'incomplete startup packet'
s.connect((domain, port))
@@ -104,8 +106,12 @@ class SiteManager:
print("Database is ready.")
break
except socket.error:
+ attempts_left -= 1
print("Not ready yet, retrying.")
time.sleep(0.5)
+ else:
+ print("Database could not be found, exiting.")
+ sys.exit(1)
def prepare_server(self) -> None:
"""Perform preparation tasks before running the server."""