build: updated config for redis and wait_for_db command
This commit is contained in:
parent
db10c884e8
commit
4414a71331
7 changed files with 40 additions and 21 deletions
0
apiserver/plane/db/management/__init__.py
Normal file
0
apiserver/plane/db/management/__init__.py
Normal file
0
apiserver/plane/db/management/commands/__init__.py
Normal file
0
apiserver/plane/db/management/commands/__init__.py
Normal file
19
apiserver/plane/db/management/commands/wait_for_db.py
Normal file
19
apiserver/plane/db/management/commands/wait_for_db.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import time
|
||||
from django.db import connections
|
||||
from django.db.utils import OperationalError
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Django command to pause execution until db is available"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write('Waiting for database...')
|
||||
db_conn = None
|
||||
while not db_conn:
|
||||
try:
|
||||
db_conn = connections['default']
|
||||
except OperationalError:
|
||||
self.stdout.write('Database unavailable, waititng 1 second...')
|
||||
time.sleep(1)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Database available!'))
|
||||
|
|
@ -6,17 +6,7 @@ from urllib.parse import urlparse
|
|||
|
||||
def redis_instance():
|
||||
if settings.REDIS_URL:
|
||||
tls_url = os.environ.get("REDIS_TLS_URL", False)
|
||||
url = urlparse(settings.REDIS_URL)
|
||||
if tls_url:
|
||||
url = urlparse(tls_url)
|
||||
ri = redis.Redis(
|
||||
host=url.hostname,
|
||||
port=url.port,
|
||||
password=url.password,
|
||||
ssl=True,
|
||||
ssl_cert_reqs=None,
|
||||
)
|
||||
ri = redis.from_url(settings.REDIS_URL, db=0)
|
||||
else:
|
||||
ri = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue