From 0a9b72a74e9a05a6fb4598e86a82fe038f41ff43 Mon Sep 17 00:00:00 2001 From: fmelihh Date: Fri, 19 Jul 2024 11:36:20 +0300 Subject: [PATCH] feat: service developments --- .env.docker | 3 ++ .env.local | 5 ++- docker-compose.yml | 31 ++++++++++++++++++- .../app/shared_kernel/database/clickhouse.py | 3 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.env.docker b/.env.docker index f169bdf..6a93fc3 100644 --- a/.env.docker +++ b/.env.docker @@ -4,3 +4,6 @@ REDIS_PORT=6379 ## CELERY CELERY_TIMEZONE=UTC + +## CLICKHOUSE +CLICKHOUSE_URL=clickhouse+native://default:@ch_server:8123/default diff --git a/.env.local b/.env.local index 0de4d59..c10702c 100644 --- a/.env.local +++ b/.env.local @@ -3,4 +3,7 @@ REDIS_HOST=localhost REDIS_PORT=6379 ## CELERY -CELERY_TIMEZONE=UTC \ No newline at end of file +CELERY_TIMEZONE=UTC + +#CLICKHOUSE +CLICKHOUSE_URL=clickhouse+native://default:@localhost:8123/default \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7343109..92f2571 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: container_name: search-project user: root environment: - ENV_FOR_DYNACONF: docker + - ENVIRONMENT=docker command: "python /opt/search/main.py" ports: - "8000:8000" @@ -16,6 +16,35 @@ services: - .:/opt/search depends_on: - "redis" + celery_worker: + hostname: search-celery-worker + container_name: search-celery-worker + build: + context: . + dockerfile: Dockerfile + environment: + - ENVIRONMENT=docker + command: > + bash -c "celery -A main.celery_app worker -l info -E -Q periodic,daily" + volumes: + - .:/opt/b2m + depends_on: + - "redis" + celery-beat: + image: search-celery-beat + hostname: search-celery-beat + build: + context: . + dockerfile: Dockerfile + environment: + - ENVIRONMENT=docker + command: > + bash -c " celery -A b2metric.celery.app beat -s data/redis/scheduler.db -S redbeat.RedBeatScheduler -l INFO" + volumes: + - .:/opt/b2m + depends_on: + - "search-project" + - "redis" redis: image: redis hostname: redis diff --git a/src/recommendation_engine/app/shared_kernel/database/clickhouse.py b/src/recommendation_engine/app/shared_kernel/database/clickhouse.py index 1a0ff3b..4395a51 100644 --- a/src/recommendation_engine/app/shared_kernel/database/clickhouse.py +++ b/src/recommendation_engine/app/shared_kernel/database/clickhouse.py @@ -1,3 +1,4 @@ +import os from loguru import logger from typing import Iterator @@ -6,7 +7,7 @@ from sqlalchemy.ext.declarative import declarative_base -engine = create_engine("clickhouse+native://default:@localhost/default", future=True) +engine = create_engine("clickhouse+native://default:@localhost:8123/default", future=True) SessionLocal = sessionmaker( autocommit=False,