This commit is contained in:
2024-06-17 18:17:36 +05:00
parent 211f206e86
commit 7f9afc592c
5 changed files with 26 additions and 31 deletions
+11 -12
View File
@@ -34,6 +34,7 @@ app.get("/start", async (req, res) => {
const location = req.query.location as string;
const buildName = req.query.build as string;
const ownerIp = req.headers["x-real-ip"];
const endAt = req.query.endAt as string;
let type = req.query.type as string;
console.log("location", location);
@@ -47,8 +48,6 @@ app.get("/start", async (req, res) => {
type = "demo";
}
console.log("type", type);
const build = await getBuild(buildName);
if (!build) {
@@ -63,9 +62,6 @@ app.get("/start", async (req, res) => {
type,
});
console.log("type", type);
console.log("activeSessionsWithBuild", activeSessionsWithBuild);
if (
type === "demo" &&
build.demoLaunchLimit &&
@@ -99,7 +95,7 @@ app.get("/start", async (req, res) => {
const sessionServerUrl = `https://${location}.sess.stream.graff.tech/${sessionServer.name}`;
// const sessionServerUrl = "http://localhost:3000";
console.log(`${sessionServerUrl}/start`);
console.log("endAt", endAt);
try {
const result: any = await got
@@ -107,6 +103,7 @@ app.get("/start", async (req, res) => {
json: {
buildName,
ownerIp,
endAt,
},
})
.json();
@@ -227,7 +224,7 @@ async function checkScheduledSessions() {
for (const session of scheduledSessions) {
if (
isAfter(new Date(), parseISO(session.startAt)) &&
isAfter(new Date(), new Date(session.startAt)) &&
!session.activeSessionId
) {
console.log("session.buildId", session.buildId);
@@ -238,7 +235,9 @@ async function checkScheduledSessions() {
console.log("build", build);
const result: any = await got
.get(`https://coord.graff.tech/start?build=${build}&location=a1`)
.get(
`https://coord.graff.tech/start?build=${build}&location=a1&type=prod&endAt=${session.endAt}`
)
.json();
if (!result.stream) {
@@ -255,11 +254,11 @@ async function checkScheduledSessions() {
.json();
console.log("result2: ", result2);
} else if (isAfter(new Date(), parseISO(session.endAt))) {
} else if (isAfter(new Date(), new Date(session.endAt))) {
const result = await got
.post(
`https://coord.graff.tech/active_sessions/${session.activeSessionId}/end`
)
.post(`https://coord.graff.tech/end`, {
json: { activeSessionId: session.activeSessionId },
})
.json();
console.log("CRON End active session: ", result);
+3
View File
@@ -32,6 +32,9 @@ const activeSessionSchema = new Schema(
connectedPlayersCount: {
type: Number,
},
endAt: {
type: Date,
},
},
{
timestamps: true,
-11
View File
@@ -1,11 +0,0 @@
import { Router } from "express";
const router = Router();
router.get("/", async (req, res) => {
res.json({ ok: 1 });
});
const testRouter = router;
export default testRouter;