Skip to content

Commit 9eb19d4

Browse files
committed
fix: resolve port 9000 collision by making metrics server conditional
1 parent e68ba1e commit 9eb19d4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

backend/config/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class Settings(BaseSettings):
5454
SLACK_LOG_CHANNEL: str = "C077Z79HB0V"
5555
# n8n
5656
N8N_WEBHOOK_URL: str = "http://n8n:5678/webhook/publish-post"
57+
# Metrics
58+
START_METRICS: bool = False
59+
METRICS_PORT: int = 9000
60+
5761
# Pydantic configuration
5862
model_config = SettingsConfigDict(
5963
env_file=".env", env_file_encoding="utf-8", extra="ignore"

backend/workers/broker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
@broker.on_event(TaskiqEvents.WORKER_STARTUP)
3434
async def start_metrics_server(_state: Any) -> None:
35-
start_http_server(9000)
35+
if settings.START_METRICS:
36+
start_http_server(settings.METRICS_PORT)
3637

3738

3839
# Initialise the scheduler with label and Redis sources

infra/docker-compose.prod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- POSTGRES_HOST=postgres
1313
- REDIS_HOST=redis
1414
- QDRANT_HOST=qdrant
15+
- START_METRICS=false
1516
depends_on:
1617
postgres:
1718
condition: service_healthy
@@ -29,6 +30,10 @@ services:
2930
- POSTGRES_HOST=postgres
3031
- REDIS_HOST=redis
3132
- QDRANT_HOST=qdrant
33+
- START_METRICS=true
34+
- METRICS_PORT=9000
35+
ports:
36+
- "9000:9000"
3237
depends_on:
3338
postgres:
3439
condition: service_healthy
@@ -44,6 +49,10 @@ services:
4449
env_file: .env
4550
environment:
4651
- REDIS_HOST=redis
52+
- START_METRICS=true
53+
- METRICS_PORT=9001
54+
ports:
55+
- "9001:9001"
4756
depends_on:
4857
redis:
4958
condition: service_healthy

0 commit comments

Comments
 (0)