Skip to content

Commit

Permalink
refactor: define redis port as env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
injoonH committed Apr 5, 2024
1 parent aa51697 commit 30feb3c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .docker/run-celery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ done

sleep 5

while ! nc -vz $NEWARA_REDIS_ADDRESS 6379; do
while ! nc -vz $NEWARA_REDIS_ADDRESS $NEWARA_REDIS_PORT; do
>&2 echo "Redis is unavailable - sleeping"
sleep 1
done
Expand Down
2 changes: 1 addition & 1 deletion .docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ while ! nc -vz $NEWARA_DB_HOST $NEWARA_DB_PORT; do
sleep 1
done

while ! nc -vz $NEWARA_REDIS_ADDRESS 6379; do
while ! nc -vz $NEWARA_REDIS_ADDRESS $NEWARA_REDIS_PORT; do
>&2 echo "Redis is unavailable - sleeping"
sleep 1
done
Expand Down
4 changes: 2 additions & 2 deletions ara/settings/cacheops.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .redis import REDIS_HOST
from .redis import REDIS_HOST, REDIS_PORT

CACHEOPS_REDIS = {
"host": REDIS_HOST,
"port": 6379,
"port": REDIS_PORT,
"db": 1,
}

Expand Down
4 changes: 3 additions & 1 deletion ara/settings/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from os import environ as os_environ

REDIS_HOST = os_environ.get("NEWARA_REDIS_ADDRESS", "localhost")
REDIS_PORT = os_environ.get("NEWARA_REDIS_PORT", 6379)
REDIS_DATABASE = int(os_environ.get("NEWARA_REDIS_DATABASE", 0))
REDIS_URL = f"redis://{REDIS_HOST}:6379/{REDIS_DATABASE}"

REDIS_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DATABASE}"

CACHES_TIMEOUT = timedelta(days=14)

Expand Down
2 changes: 1 addition & 1 deletion ara/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

REDIS_DATABASE = int(environ.get("NEWARA_REDIS_DATABASE", 2))
REDIS_URL = f"redis://{REDIS_HOST}:6379/{REDIS_DATABASE}"
REDIS_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DATABASE}"

CELERY_TASK_ALWAYS_EAGER = True
ELASTICSEARCH_INDEX_NAME = "articles_test"
Expand Down

0 comments on commit 30feb3c

Please sign in to comment.