Create initialization of redis streams
This commit is contained in:
parent
07bedda2c0
commit
3ea241ebbd
@ -13,3 +13,4 @@ JTW_SECRET=SECRETHERE
|
|||||||
FORCE_DB_SYNC=true # Use false during production
|
FORCE_DB_SYNC=true # Use false during production
|
||||||
|
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
DEVICE_ID=backend
|
||||||
@ -52,6 +52,28 @@ redis.client = Redis.createClient({
|
|||||||
redis.client.on('error', (err) => console.error('Redis error:', err));
|
redis.client.on('error', (err) => console.error('Redis error:', err));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const initializeStreams = async () => {
|
||||||
|
try {
|
||||||
|
await redis.client.connect().catch(console.error);
|
||||||
|
|
||||||
|
console.log("Initializing Redis Streams...");
|
||||||
|
|
||||||
|
// Create transcriptions streams consumer group
|
||||||
|
await client.xGroupCreate("communication", "mtf-devices", '0', {MKSTREAM: true});
|
||||||
|
|
||||||
|
console.log("Created consumer group: mtf-devices (communication)");
|
||||||
|
} catch (err) {
|
||||||
|
if (err.message.includes('BUSYGROUP')) {
|
||||||
|
console.log("Consumer group already exists: mtf-devices");
|
||||||
|
} else {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deviceIds = [""]
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
db,
|
db,
|
||||||
redis
|
redis
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user