Skip to content

Commit

Permalink
Rewrite queue in-memory instead of redis
Browse files Browse the repository at this point in the history
  • Loading branch information
soruly committed Mar 10, 2024
1 parent 9a50793 commit 5477768
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 186 deletions.
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ SOLA_DB_USER=sola
SOLA_DB_PWD=sola
SOLA_DB_NAME=sola

# Redis setting
REDIS_HOST=127.0.0.1
REDIS_PORT=6379

# Solr setting
SOLA_SOLR_LIST=http://127.0.0.1:8983/solr/
SOLA_SOLR_SIZE=1
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

services:
redis:
image: redis
ports:
- 6379:6379
mariadb:
image: mariadb
env:
Expand All @@ -45,8 +41,6 @@ jobs:
- run: npm ci
- run: npm run jest
env:
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
SOLA_DB_HOST: 127.0.0.1
SOLA_DB_PORT: 3306
SOLA_DB_USER: root
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ API server for [trace.moe](https://github.com/soruly/trace.moe)
- mariaDB 10.4.x
- ffmpeg 4.x
- java (openjdk 17)
- redis
- [liresolr](https://github.com/soruly/liresolr)
- g++, cmake (if you need to compile OpenCV)

Expand Down
7 changes: 0 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ services:
networks:
trace_moe_net:

redis:
image: redis:latest
ports:
- ${REDIS_PORT}:6379
networks:
trace_moe_net:

liresolr:
image: ghcr.io/soruly/liresolr:latest
command: solr-precreate cl_0 /opt/solr/server/solr/configsets/liresolr
Expand Down
81 changes: 0 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"multer": "^1.4.5-lts.1",
"mysql": "^2.18.1",
"nodemailer": "^6.9.12",
"redis": "^4.6.13",
"rss": "^1.2.2",
"xmldoc": "^1.3.0"
}
Expand Down
34 changes: 0 additions & 34 deletions script/redis.js

This file was deleted.

17 changes: 8 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "dotenv/config";
import fs from "fs-extra";
import Knex from "knex";
import { createClient } from "redis";

import app from "./src/app.js";

Expand All @@ -18,8 +17,6 @@ const {
SOLA_DB_PWD,
SOLA_DB_NAME,
SERVER_PORT,
REDIS_HOST,
REDIS_PORT,
} = process.env;

console.log("Creating SQL database if not exist");
Expand All @@ -33,12 +30,6 @@ await Knex({
},
}).raw(`CREATE DATABASE IF NOT EXISTS ${SOLA_DB_NAME} CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;`);

app.locals.redis = createClient({
url: `redis://${REDIS_HOST}:${REDIS_PORT}`,
});
await app.locals.redis.connect();
await app.locals.redis.flushAll();

app.locals.knex = Knex({
client: "mysql",
connection: {
Expand All @@ -60,6 +51,14 @@ await app.locals.knex.raw(fs.readFileSync("sql/data.sql", "utf8"));
app.locals.workerCount = 0;
app.locals.mutex = false;
app.locals.mediaQueue = 0;
app.locals.searchQueue = [];
app.locals.searchConcurrent = new Map();
setInterval(() => app.locals.searchConcurrent.clear(), 60 * 60 * 1000);
setInterval(() => (app.locals.searchQueue = []), 60 * 60 * 1000);
setInterval(() => {
console.log("queue", app.locals.searchQueue);
console.log("concurrent", app.locals.searchConcurrent);
}, 60 * 1000);

const server = app.listen(SERVER_PORT, "0.0.0.0", () =>
console.log(`API server listening on port ${server.address().port}`),
Expand Down
Loading

0 comments on commit 5477768

Please # to comment.