From 3f930760caf67f72793ee4ef31854fae59c78c34 Mon Sep 17 00:00:00 2001 From: marax Date: Thu, 4 Nov 2021 17:32:02 +0100 Subject: [PATCH] change wait_for_db file --- app1/management/commands/wait_for_db.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app1/management/commands/wait_for_db.py b/app1/management/commands/wait_for_db.py index f6be870..981f116 100644 --- a/app1/management/commands/wait_for_db.py +++ b/app1/management/commands/wait_for_db.py @@ -12,17 +12,19 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): """ Django wait for DB""" - self.stdout.write('Waiting for Database ...') - db_up = False - while db_up is False: - try: - self.check(database=['default']) - db_up = True - except (Psycopg2OpError, OperationalError): - self.stdout.write('Database unavailable, waiting 1 sec...') - time.sleep(1) + + def handle(self, *args, **options): + self.stdout.write('Waiting for Database ...') + db_up = False + while db_up is False: + try: + self.check(database=['default']) + db_up = True + except (Psycopg2OpError, OperationalError): + self.stdout.write('Database unavailable, waiting 1 sec...') + time.sleep(1) - self.stdout.write(self.style.SUCCESS('database ready !!')) + self.stdout.write(self.style.SUCCESS('database ready !!'))