Dispatch-Chron Jobs in Core-Server verschoben #65
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
REDIS_HOST=localhost
|
||||||
|
REDIS_PORT=6379
|
||||||
DISCORD_SERVER_PORT=3005
|
DISCORD_SERVER_PORT=3005
|
||||||
DISCORD_GUILD_ID=1077269395019141140
|
DISCORD_GUILD_ID=1077269395019141140
|
||||||
DISCORD_OAUTH_CLIENT_ID=930384053344034846
|
DISCORD_OAUTH_CLIENT_ID=930384053344034846
|
||||||
|
|||||||
@@ -3,10 +3,19 @@ import express from "express";
|
|||||||
import { createServer } from "http";
|
import { createServer } from "http";
|
||||||
import router from "routes/router";
|
import router from "routes/router";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
|
import { Server } from "socket.io";
|
||||||
|
import { createAdapter } from "@socket.io/redis-adapter";
|
||||||
|
import { pubClient, subClient } from "modules/redis";
|
||||||
|
import "modules/chron";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = createServer(app);
|
const server = createServer(app);
|
||||||
|
|
||||||
|
export const io = new Server(server, {
|
||||||
|
adapter: createAdapter(pubClient, subClient),
|
||||||
|
cors: {},
|
||||||
|
});
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|||||||
@@ -58,9 +58,8 @@ const removeClosedMissions = async () => {
|
|||||||
l.data?.newFMSstatus === "6"
|
l.data?.newFMSstatus === "6"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
status4Log !== -1 &&
|
(status4Log !== -1 || status8Log !== -1) &&
|
||||||
(status1Log !== -1 || status6Log !== -1) &&
|
(status1Log !== -1 || status6Log !== -1) &&
|
||||||
(status4Log < status1Log ||
|
(status4Log < status1Log ||
|
||||||
status8Log < status1Log ||
|
status8Log < status1Log ||
|
||||||
@@ -124,6 +123,7 @@ const removeClosedMissions = async () => {
|
|||||||
console.log(`Mission ${mission.id} closed due to inactivity.`);
|
console.log(`Mission ${mission.id} closed due to inactivity.`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeConnectedAircrafts = async () => {
|
const removeConnectedAircrafts = async () => {
|
||||||
const connectedAircrafts = await prisma.connectedAircraft.findMany({
|
const connectedAircrafts = await prisma.connectedAircraft.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -144,7 +144,7 @@ const removeConnectedAircrafts = async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
removeClosedMissions();
|
||||||
cron.schedule("*/1 * * * *", async () => {
|
cron.schedule("*/1 * * * *", async () => {
|
||||||
try {
|
try {
|
||||||
await removeClosedMissions();
|
await removeClosedMissions();
|
||||||
13
apps/core-server/modules/redis.ts
Normal file
13
apps/core-server/modules/redis.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { createClient, RedisClientType } from "redis";
|
||||||
|
|
||||||
|
export const pubClient: RedisClientType = createClient({
|
||||||
|
url: `redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`,
|
||||||
|
});
|
||||||
|
export const subClient: RedisClientType = pubClient.duplicate();
|
||||||
|
|
||||||
|
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
||||||
|
console.log("Redis connected");
|
||||||
|
});
|
||||||
|
|
||||||
|
pubClient.on("error", (err: unknown) => console.log("Redis Client Error", err));
|
||||||
|
subClient.on("error", (err: unknown) => console.log("Redis Client Error", err));
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"typescript": "latest"
|
"typescript": "latest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@socket.io/redis-adapter": "^8.3.0",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cron": "^4.3.1",
|
"cron": "^4.3.1",
|
||||||
@@ -30,6 +31,8 @@
|
|||||||
"nodemon": "^3.1.10",
|
"nodemon": "^3.1.10",
|
||||||
"prom-client": "^15.1.3",
|
"prom-client": "^15.1.3",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
|
"redis": "^5.1.1",
|
||||||
|
"socket.io": "^4.8.1",
|
||||||
"tsx": "^4.19.4"
|
"tsx": "^4.19.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { handleConnectDesktop } from "socket-events/connect-desktop";
|
|||||||
import cookieParser from "cookie-parser";
|
import cookieParser from "cookie-parser";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import { authMiddleware } from "modules/expressMiddleware";
|
import { authMiddleware } from "modules/expressMiddleware";
|
||||||
import "modules/chron";
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = createServer(app);
|
const server = createServer(app);
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ export const subClient: RedisClientType = pubClient.duplicate();
|
|||||||
|
|
||||||
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
||||||
console.log("Redis connected");
|
console.log("Redis connected");
|
||||||
pubClient.keys("dispatchers*").then((keys) => {
|
|
||||||
if (!keys) return;
|
|
||||||
keys.forEach(async (key) => {
|
|
||||||
await pubClient.json.del(key);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
pubClient.on("error", (err) => console.log("Redis Client Error", err));
|
pubClient.on("error", (err) => console.log("Redis Client Error", err));
|
||||||
|
|||||||
43
pnpm-lock.yaml
generated
43
pnpm-lock.yaml
generated
@@ -24,6 +24,9 @@ importers:
|
|||||||
|
|
||||||
apps/core-server:
|
apps/core-server:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@socket.io/redis-adapter':
|
||||||
|
specifier: ^8.3.0
|
||||||
|
version: 8.3.0(socket.io-adapter@2.5.5)
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.9.0
|
specifier: ^1.9.0
|
||||||
version: 1.9.0
|
version: 1.9.0
|
||||||
@@ -54,6 +57,12 @@ importers:
|
|||||||
react:
|
react:
|
||||||
specifier: ^19.1.0
|
specifier: ^19.1.0
|
||||||
version: 19.1.0
|
version: 19.1.0
|
||||||
|
redis:
|
||||||
|
specifier: ^5.1.1
|
||||||
|
version: 5.1.1
|
||||||
|
socket.io:
|
||||||
|
specifier: ^4.8.1
|
||||||
|
version: 4.8.1
|
||||||
tsx:
|
tsx:
|
||||||
specifier: ^4.19.4
|
specifier: ^4.19.4
|
||||||
version: 4.19.4
|
version: 4.19.4
|
||||||
@@ -102,7 +111,7 @@ importers:
|
|||||||
version: 0.5.7(@types/dom-mediacapture-transform@0.1.11)(livekit-client@2.14.0(@types/dom-mediacapture-record@1.0.22))
|
version: 0.5.7(@types/dom-mediacapture-transform@0.1.11)(livekit-client@2.14.0(@types/dom-mediacapture-record@1.0.22))
|
||||||
'@next-auth/prisma-adapter':
|
'@next-auth/prisma-adapter':
|
||||||
specifier: ^1.0.7
|
specifier: ^1.0.7
|
||||||
version: 1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))
|
version: 1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))
|
||||||
'@radix-ui/react-icons':
|
'@radix-ui/react-icons':
|
||||||
specifier: ^1.3.2
|
specifier: ^1.3.2
|
||||||
version: 1.3.2(react@19.1.0)
|
version: 1.3.2(react@19.1.0)
|
||||||
@@ -186,7 +195,7 @@ importers:
|
|||||||
version: 15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
version: 15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
next-auth:
|
next-auth:
|
||||||
specifier: ^4.24.11
|
specifier: ^4.24.11
|
||||||
version: 4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
version: 4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
npm:
|
npm:
|
||||||
specifier: ^11.4.2
|
specifier: ^11.4.2
|
||||||
version: 11.4.2
|
version: 11.4.2
|
||||||
@@ -350,7 +359,7 @@ importers:
|
|||||||
version: 5.1.1(react-hook-form@7.59.0(react@19.1.0))
|
version: 5.1.1(react-hook-form@7.59.0(react@19.1.0))
|
||||||
'@next-auth/prisma-adapter':
|
'@next-auth/prisma-adapter':
|
||||||
specifier: ^1.0.7
|
specifier: ^1.0.7
|
||||||
version: 1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))
|
version: 1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))
|
||||||
'@radix-ui/react-icons':
|
'@radix-ui/react-icons':
|
||||||
specifier: ^1.3.2
|
specifier: ^1.3.2
|
||||||
version: 1.3.2(react@19.1.0)
|
version: 1.3.2(react@19.1.0)
|
||||||
@@ -425,7 +434,7 @@ importers:
|
|||||||
version: 15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
version: 15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
next-auth:
|
next-auth:
|
||||||
specifier: ^4.24.11
|
specifier: ^4.24.11
|
||||||
version: 4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
version: 4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
next-remove-imports:
|
next-remove-imports:
|
||||||
specifier: ^1.0.12
|
specifier: ^1.0.12
|
||||||
version: 1.0.12(webpack@5.99.9)
|
version: 1.0.12(webpack@5.99.9)
|
||||||
@@ -572,7 +581,7 @@ importers:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
specifier: ^8.36.0
|
specifier: ^8.36.0
|
||||||
version: 8.36.0(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
version: 8.36.0(@typescript-eslint/parser@8.35.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@eslint/js':
|
'@eslint/js':
|
||||||
specifier: ^9.17.0
|
specifier: ^9.17.0
|
||||||
@@ -6954,10 +6963,10 @@ snapshots:
|
|||||||
'@tybys/wasm-util': 0.9.0
|
'@tybys/wasm-util': 0.9.0
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@next-auth/prisma-adapter@1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))':
|
'@next-auth/prisma-adapter@1.0.7(@prisma/client@6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3))(next-auth@4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@prisma/client': 6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3)
|
'@prisma/client': 6.8.2(prisma@6.8.2(typescript@5.8.3))(typescript@5.8.3)
|
||||||
next-auth: 4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
next-auth: 4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
|
|
||||||
'@next/env@15.3.4': {}
|
'@next/env@15.3.4': {}
|
||||||
|
|
||||||
@@ -8743,10 +8752,10 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.36.0(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)':
|
'@typescript-eslint/eslint-plugin@8.36.0(@typescript-eslint/parser@8.35.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/regexpp': 4.12.1
|
'@eslint-community/regexpp': 4.12.1
|
||||||
'@typescript-eslint/parser': 8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
'@typescript-eslint/parser': 8.35.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
||||||
'@typescript-eslint/scope-manager': 8.36.0
|
'@typescript-eslint/scope-manager': 8.36.0
|
||||||
'@typescript-eslint/type-utils': 8.36.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
'@typescript-eslint/type-utils': 8.36.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
||||||
'@typescript-eslint/utils': 8.36.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
'@typescript-eslint/utils': 8.36.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)
|
||||||
@@ -8818,6 +8827,18 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
'@typescript-eslint/parser@8.35.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)':
|
||||||
|
dependencies:
|
||||||
|
'@typescript-eslint/scope-manager': 8.35.0
|
||||||
|
'@typescript-eslint/types': 8.35.0
|
||||||
|
'@typescript-eslint/typescript-estree': 8.35.0(typescript@5.8.3)
|
||||||
|
'@typescript-eslint/visitor-keys': 8.35.0
|
||||||
|
debug: 4.4.1(supports-color@5.5.0)
|
||||||
|
eslint: 9.28.0(jiti@2.4.2)
|
||||||
|
typescript: 5.8.3
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/parser@8.35.0(eslint@9.30.0(jiti@2.4.2))(typescript@5.8.3)':
|
'@typescript-eslint/parser@8.35.0(eslint@9.30.0(jiti@2.4.2))(typescript@5.8.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/scope-manager': 8.35.0
|
'@typescript-eslint/scope-manager': 8.35.0
|
||||||
@@ -9962,7 +9983,7 @@ snapshots:
|
|||||||
engine.io@6.6.4:
|
engine.io@6.6.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/cors': 2.8.18
|
'@types/cors': 2.8.18
|
||||||
'@types/node': 22.15.29
|
'@types/node': 22.15.34
|
||||||
accepts: 1.3.8
|
accepts: 1.3.8
|
||||||
base64id: 2.0.0
|
base64id: 2.0.0
|
||||||
cookie: 0.7.2
|
cookie: 0.7.2
|
||||||
@@ -11886,7 +11907,7 @@ snapshots:
|
|||||||
|
|
||||||
neo-async@2.6.2: {}
|
neo-async@2.6.2: {}
|
||||||
|
|
||||||
next-auth@4.24.11(next@15.3.4(@babel/core@7.27.7)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
|
next-auth@4.24.11(next@15.3.4(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.27.6
|
'@babel/runtime': 7.27.6
|
||||||
'@panva/hkdf': 1.2.1
|
'@panva/hkdf': 1.2.1
|
||||||
|
|||||||
Reference in New Issue
Block a user