Browse Source

change wait_for_db file

master
marax 3 years ago
parent
commit
3f930760ca
1 changed files with 12 additions and 10 deletions
  1. +12
    -10
      app1/management/commands/wait_for_db.py

+ 12
- 10
app1/management/commands/wait_for_db.py View File

@ -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 !!'))


Loading…
Cancel
Save

Powered by TurnKey Linux.