Skip to content

Commit 693b546

Browse files
committed
Update env to enable matching service to run locally and in docker
1 parent 5236990 commit 693b546

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Backend/MatchingService/rabbitmq/setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const dead_letter_queue_name = "dead_letter_queue";
77
// const cancel_queue_name = "cancel_queue";
88
const difficulties = ["easy", "medium", "hard", "any"];
99
const axios = require('axios');
10-
const categoryAPIUrl = 'http://question-service:3001/api/categories';
10+
// Matching Service code
11+
const questionServiceHost = process.env.QUESTION_SERVICE_HOST || 'localhost';
12+
const categoryAPIUrl = `http://${questionServiceHost}:3001/api/categories`;
1113

1214
let queueNamesPromise = axios.get(categoryAPIUrl)
1315
.then(response => {

Backend/MatchingService/rabbitmq/subscriber.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const { notifyUsers } = require('../websocket/websocket');
55
const { v4: uuidv4 } = require('uuid');
66
// matchingService/fetchQuestion.js
77
const axios = require('axios');
8-
const questionAPIUrl = 'http://question-service:3001/api/questions';
8+
// Matching Service code
9+
const questionServiceHost = process.env.QUESTION_SERVICE_HOST || 'localhost';
10+
const questionAPIUrl = `http://${questionServiceHost}:3001/api/questions`;
911

1012

1113
// TODO: Subscribe and acknowledge messages with user info when timeout/user matched

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ services:
2424
dockerfile: Dockerfile
2525
ports:
2626
- "8080:8080"
27+
environment:
28+
- QUESTION_SERVICE_HOST=question-service
2729
depends_on:
2830
question-service:
2931
condition: service_healthy

0 commit comments

Comments
 (0)