Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Sefaria/LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz committed Mar 5, 2024
2 parents a4fd955 + 03794f0 commit 95304fb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/celery_setup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
sentinel_url = os.getenv('SENTINEL_HEADLESS_URL')
sentinel_transport_opts = json.loads(os.getenv('SENTINEL_TRANSPORT_OPTS', '{}'))
redis_url = os.getenv('REDIS_URL')
redis_password = os.getenv('REDIS_PASSWORD')


def add_db_num_to_url(url, db_num):
return url.replace(f':{redis_port}', f':{redis_port}/{db_num}')


def add_password_to_url(url, password):
if len(password) == 0:
return url
return url.replace('redis://', f'redis://:{password}@')


if sentinel_url:
redisdns = dns.resolver.resolve(sentinel_url, 'A')
addressstring = []
Expand All @@ -30,5 +37,6 @@ def add_db_num_to_url(url, db_num):
result_backend_transport_options = sentinel_transport_opts
broker_transport_options = sentinel_transport_opts
else:
broker_url = add_db_num_to_url(f"{redis_url}:{redis_port}", broker_db_num)
result_backend = add_db_num_to_url(f"{redis_url}:{redis_port}", result_backend_db_num)
redis_url = add_password_to_url(f"{redis_url}:{redis_port}", redis_password)
broker_url = add_db_num_to_url(redis_url, broker_db_num)
result_backend = add_db_num_to_url(redis_url, result_backend_db_num)

0 comments on commit 95304fb

Please sign in to comment.