Compare commits

..

No commits in common. "ba8c33d8fc7a61154bc81c4c0f6826f1bbc295ff" and "054e9caca065aeb898985579aff69c96c94dfb57" have entirely different histories.

4 changed files with 17 additions and 23 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 xf RUN useradd -d /code pathogen
RUN mkdir /code RUN mkdir /code
RUN chown xf:xf /code RUN chown pathogen:pathogen /code
RUN mkdir /venv RUN mkdir /venv
RUN chown xf:xf /venv RUN chown pathogen:pathogen /venv
USER xf USER pathogen
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 --names docker-compose -f docker-compose.prod.yml --env-file=stack.env logs -f
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://127.0.0.1:9308") configuration = manticoresearch.Configuration(host="http://monolith_db:9308")
api_client = manticoresearch.ApiClient(configuration) api_client = manticoresearch.ApiClient(configuration)
api_instance = manticoresearch.IndexApi(api_client) api_instance = manticoresearch.IndexApi(api_client)
@ -23,21 +23,17 @@ 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="127.0.0.1", # Replace with your Redis server's IP address host="ssdb_monolith", # 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://127.0.0.1:1289", "redis://ssdb_monolith: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"
@ -161,20 +157,19 @@ 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 INDEX", index, body_post) # print(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:
log.error("Exception when calling IndexApi->bulk: %s\n" % e) print("Exception when calling IndexApi->bulk: %s\n" % e)
log.error("body_post attempted to send", body_post) print(f"Completed ingest to MC of length {len(total)}")
log.info(f"Completed ingest to MC of length {len(total)}")
# END MESSAGES IN SPLIT # END MESSAGES IN SPLIT

View File

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