Update socket and database URLs

This commit is contained in:
Mark Veidemanis 2025-01-23 11:27:51 +00:00
parent 2ef2249be7
commit ba8c33d8fc
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 18 additions and 12 deletions

21
db.py
View File

@ -14,7 +14,7 @@ from schemas import mc_s
from os import getenv
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_instance = manticoresearch.IndexApi(api_client)
@ -23,17 +23,21 @@ log = util.get_logger("db")
# Redis (legacy)
# r = StrictRedis(unix_socket_path="/var/run/redis/redis.sock", db=0)
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
db=0 # Database number
)
# AIORedis
# ar = aioredis.from_url("unix:///var/run/redis/redis.sock", db=0)
ar = aioredis.from_url(
"redis://ssdb_monolith:1289",
"redis://127.0.0.1:1289",
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"
MESSAGE_KEY = "messages"
@ -157,19 +161,20 @@ async def store_batch(data):
body_post = ""
for item in total:
print("ITEM", item)
#print("ITEM", item)
body_post += orjson.dumps(item).decode("utf-8")
body_post += "\n"
# print(body_post)
#print("BODY POST INDEX", index, body_post)
try:
# Bulk index operations
api_response = api_instance.bulk(body_post) # , async_req=True
except ApiException as e:
print("Exception when calling IndexApi->bulk: %s\n" % e)
print(f"Completed ingest to MC of length {len(total)}")
log.error("Exception when calling IndexApi->bulk: %s\n" % e)
log.error("body_post attempted to send", body_post)
log.info(f"Completed ingest to MC of length {len(total)}")
# END MESSAGES IN SPLIT

View File

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