Skip to content

Commit 1517c14

Browse files
authored
Merge pull request #67 from harshraj22/auth_db
Auth db
2 parents 86a802e + 0f77b97 commit 1517c14

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ services:
1818
image: harshraj22/dis_sim_similarity
1919
user: nobody
2020
depends_on:
21-
- redis
21+
redis:
22+
condition: service_healthy
2223

2324
frontend:
2425
build: './src/frontend'
@@ -36,6 +37,9 @@ services:
3637
image: harshraj22/dis_sim_auth
3738
ports:
3839
- '8019:8019'
40+
depends_on:
41+
data_population:
42+
condition: service_healthy
3943

4044
redis:
4145
image: 'redis:4-alpine'
@@ -146,6 +150,11 @@ services:
146150
environment:
147151
- REDIS_URL=redis
148152
- REDIS_PORT=6379
153+
healthcheck:
154+
test: ["CMD", "python3", "healthcheck.py"]
155+
interval: 10s
156+
timeout: 5s
157+
retries: 3
149158
depends_on:
150159
redis:
151160
condition: service_healthy

src/auth/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ passlib
44
bcrypt
55
fastapi
66
uvicorn
7-
requests
7+
requests
8+
python-multipart

src/data_population/healthcheck.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import requests
2+
3+
url = "http://data_population:8020/healthcheck"
4+
5+
try:
6+
response = requests.get(url)
7+
response.raise_for_status()
8+
except requests.exceptions.RequestException as e:
9+
# The request failed, so exit with a non-zero code to indicate failure
10+
exit(1)

src/data_population/populate.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def sync_all():
5656
for username, subscription_tier, request_limit, retention_period in result:
5757
r.set(f'{ALLOWED_PREFIX}-{username}', request_limit)
5858

59+
@app.get('/healthcheck', status_code=200)
60+
def healthcheck():
61+
return 'OK'
62+
5963
# r.close()
6064
if __name__ == '__main__':
6165
requests.get('http://data_population:8020/sync_all/')

src/similarity/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
broker='redis://redis:6379/0'
1313
)
1414

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

1818
result_backend_transport_options = {
@@ -30,15 +30,15 @@
3030
'fanout_ttl': 600,
3131
'fanout_retry': True,
3232
'fanout_transport_options': {
33-
'master': 'redis://localhost:6379/0',
33+
'master': 'redis://redis:6379/0',
3434
'slaves': redis_slave_urls
3535
}
3636
}
3737

38-
app.conf.update(
39-
result_backend='redis',
40-
result_backend_transport_options=result_backend_transport_options
41-
)
38+
# app.conf.update(
39+
# result_backend='redis',
40+
# result_backend_transport_options=result_backend_transport_options
41+
# )
4242

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

0 commit comments

Comments
 (0)