Skip to content

Commit

Permalink
Merge pull request #67 from harshraj22/auth_db
Browse files Browse the repository at this point in the history
Auth db
  • Loading branch information
harshraj22 authored Apr 25, 2023
2 parents 86a802e + 0f77b97 commit 1517c14
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ services:
image: harshraj22/dis_sim_similarity
user: nobody
depends_on:
- redis
redis:
condition: service_healthy

frontend:
build: './src/frontend'
Expand All @@ -36,6 +37,9 @@ services:
image: harshraj22/dis_sim_auth
ports:
- '8019:8019'
depends_on:
data_population:
condition: service_healthy

redis:
image: 'redis:4-alpine'
Expand Down Expand Up @@ -146,6 +150,11 @@ services:
environment:
- REDIS_URL=redis
- REDIS_PORT=6379
healthcheck:
test: ["CMD", "python3", "healthcheck.py"]
interval: 10s
timeout: 5s
retries: 3
depends_on:
redis:
condition: service_healthy
Expand Down
3 changes: 2 additions & 1 deletion src/auth/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ passlib
bcrypt
fastapi
uvicorn
requests
requests
python-multipart
10 changes: 10 additions & 0 deletions src/data_population/healthcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import requests

url = "http://data_population:8020/healthcheck"

try:
response = requests.get(url)
response.raise_for_status()
except requests.exceptions.RequestException as e:
# The request failed, so exit with a non-zero code to indicate failure
exit(1)
4 changes: 4 additions & 0 deletions src/data_population/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def sync_all():
for username, subscription_tier, request_limit, retention_period in result:
r.set(f'{ALLOWED_PREFIX}-{username}', request_limit)

@app.get('/healthcheck', status_code=200)
def healthcheck():
return 'OK'

# r.close()
if __name__ == '__main__':
requests.get('http://data_population:8020/sync_all/')
Expand Down
12 changes: 6 additions & 6 deletions src/similarity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
broker='redis://redis:6379/0'
)

redis_slave_urls = os.environ.get('REDIS_SLAVE_URLS', 'redis://localhost:6379/0').split(',')
redis_slave_urls = os.environ.get('REDIS_SLAVE_URLS', 'redis://redis:6379/0').split(',')
# REDIS_SLAVE_URLS=redis://slave1:6379,redis://slave2:6379,redis://slave3:6379

result_backend_transport_options = {
Expand All @@ -30,15 +30,15 @@
'fanout_ttl': 600,
'fanout_retry': True,
'fanout_transport_options': {
'master': 'redis://localhost:6379/0',
'master': 'redis://redis:6379/0',
'slaves': redis_slave_urls
}
}

app.conf.update(
result_backend='redis',
result_backend_transport_options=result_backend_transport_options
)
# app.conf.update(
# result_backend='redis',
# result_backend_transport_options=result_backend_transport_options
# )

# frequency with which Celery checks for changes in environment variables
app.conf.beat_max_loop_interval = 60
Expand Down

0 comments on commit 1517c14

Please sign in to comment.