Compare commits

...

2 Commits

4 changed files with 23 additions and 17 deletions

View File

@ -1,14 +1,14 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM python:3.10 FROM python:3.10
RUN useradd -d /code pathogen RUN useradd -d /code xf
RUN mkdir /code RUN mkdir /code
RUN chown pathogen:pathogen /code RUN chown xf:xf /code
RUN mkdir /venv RUN mkdir /venv
RUN chown pathogen:pathogen /venv RUN chown xf:xf /venv
USER pathogen USER xf
ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
WORKDIR /code WORKDIR /code

View File

@ -8,7 +8,7 @@ stop:
docker-compose -f docker-compose.prod.yml --env-file=stack.env down docker-compose -f docker-compose.prod.yml --env-file=stack.env down
log: log:
docker-compose -f docker-compose.prod.yml --env-file=stack.env logs -f docker-compose -f docker-compose.prod.yml --env-file=stack.env logs -f --names
run-infra: run-infra:
docker-compose -f docker-compose.infra.yml --env-file=stack.env up -d docker-compose -f docker-compose.infra.yml --env-file=stack.env up -d

21
db.py
View File

@ -14,7 +14,7 @@ from schemas import mc_s
from os import getenv from os import getenv
from time import sleep from time import sleep
configuration = manticoresearch.Configuration(host="http://monolith_db:9308") configuration = manticoresearch.Configuration(host="http://127.0.0.1:9308")
api_client = manticoresearch.ApiClient(configuration) api_client = manticoresearch.ApiClient(configuration)
api_instance = manticoresearch.IndexApi(api_client) api_instance = manticoresearch.IndexApi(api_client)
@ -23,17 +23,21 @@ log = util.get_logger("db")
# Redis (legacy) # Redis (legacy)
# r = StrictRedis(unix_socket_path="/var/run/redis/redis.sock", db=0) # r = StrictRedis(unix_socket_path="/var/run/redis/redis.sock", db=0)
r = StrictRedis( r = StrictRedis(
host="ssdb_monolith", # Replace with your Redis server's IP address host="127.0.0.1", # Replace with your Redis server's IP address
port=1289, # Replace with your Redis server's port port=1289, # Replace with your Redis server's port
db=0 # Database number db=0 # Database number
) )
# AIORedis # AIORedis
# ar = aioredis.from_url("unix:///var/run/redis/redis.sock", db=0) # ar = aioredis.from_url("unix:///var/run/redis/redis.sock", db=0)
ar = aioredis.from_url( ar = aioredis.from_url(
"redis://ssdb_monolith:1289", "redis://127.0.0.1:1289",
db=0 db=0
) )
pr = aioredis.from_url("redis://redis_neptune:6379", db=10, password=getenv("REDIS_PASSWORD"))
# /var/run/neptune-redis.sock
# db = 10
pr = aioredis.from_url("unix://var/run/neptune-redis.sock", db=10)
#pr = aioredis.from_url("redis://redis_neptune:6379", db=10, password=getenv("REDIS_PASSWORD"))
KEYNAME = "queue" KEYNAME = "queue"
MESSAGE_KEY = "messages" MESSAGE_KEY = "messages"
@ -157,19 +161,20 @@ async def store_batch(data):
body_post = "" body_post = ""
for item in total: for item in total:
print("ITEM", item) #print("ITEM", item)
body_post += orjson.dumps(item).decode("utf-8") body_post += orjson.dumps(item).decode("utf-8")
body_post += "\n" body_post += "\n"
# print(body_post) #print("BODY POST INDEX", index, body_post)
try: try:
# Bulk index operations # Bulk index operations
api_response = api_instance.bulk(body_post) # , async_req=True api_response = api_instance.bulk(body_post) # , async_req=True
except ApiException as e: except ApiException as e:
print("Exception when calling IndexApi->bulk: %s\n" % e) log.error("Exception when calling IndexApi->bulk: %s\n" % e)
print(f"Completed ingest to MC of length {len(total)}") log.error("body_post attempted to send", body_post)
log.info(f"Completed ingest to MC of length {len(total)}")
# END MESSAGES IN SPLIT # END MESSAGES IN SPLIT

View File

@ -1,4 +1,5 @@
# unixsocket /var/run/socks/redis.sock unixsocket /var/run/monolith-redis.sock
# unixsocketperm 777 unixsocketperm 777
port 6379 port 0
requirepass changeme # port 6379
# requirepass changeme