diff options
author | 2019-09-29 04:30:17 +1000 | |
---|---|---|
committer | 2019-09-29 04:30:17 +1000 | |
commit | d6ad156061f175213122dc4dfbf2322a2fba7e7a (patch) | |
tree | 91618c293887e8f6971c955da83701eb40bcb6a4 /manage.py | |
parent | Remove useless verbosity check. (diff) |
Poll the database a maximum of 10 attempts before exit code 1.
Diffstat (limited to 'manage.py')
-rwxr-xr-x | manage.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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.""" |