upd
This commit is contained in:
Vendored
+9
-8
@@ -54,6 +54,7 @@ app.get("/start", async (req, res) => {
|
||||
const location = req.query.location;
|
||||
const buildName = req.query.build;
|
||||
const ownerIp = req.headers["x-real-ip"];
|
||||
const endAt = req.query.endAt;
|
||||
let type = req.query.type;
|
||||
console.log("location", location);
|
||||
console.log("buildName", buildName);
|
||||
@@ -63,7 +64,6 @@ app.get("/start", async (req, res) => {
|
||||
if (type !== "prod") {
|
||||
type = "demo";
|
||||
}
|
||||
console.log("type", type);
|
||||
const build = await getBuild(buildName);
|
||||
if (!build) {
|
||||
return res.json({ error: "Build not found" });
|
||||
@@ -74,8 +74,6 @@ app.get("/start", async (req, res) => {
|
||||
buildName,
|
||||
type,
|
||||
});
|
||||
console.log("type", type);
|
||||
console.log("activeSessionsWithBuild", activeSessionsWithBuild);
|
||||
if (type === "demo" &&
|
||||
build.demoLaunchLimit &&
|
||||
activeSessionsWithBuild.length >= build.demoLaunchLimit) {
|
||||
@@ -98,13 +96,14 @@ 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 = await got_cjs_1.default
|
||||
.post(`${sessionServerUrl}/start`, {
|
||||
json: {
|
||||
buildName,
|
||||
ownerIp,
|
||||
endAt,
|
||||
},
|
||||
})
|
||||
.json();
|
||||
@@ -197,7 +196,7 @@ async function checkScheduledSessions() {
|
||||
if (!scheduledSessions.length)
|
||||
return;
|
||||
for (const session of scheduledSessions) {
|
||||
if ((0, date_fns_1.isAfter)(new Date(), (0, date_fns_1.parseISO)(session.startAt)) &&
|
||||
if ((0, date_fns_1.isAfter)(new Date(), new Date(session.startAt)) &&
|
||||
!session.activeSessionId) {
|
||||
console.log("session.buildId", session.buildId);
|
||||
const { build } = await got_cjs_1.default
|
||||
@@ -205,7 +204,7 @@ async function checkScheduledSessions() {
|
||||
.json();
|
||||
console.log("build", build);
|
||||
const result = await got_cjs_1.default
|
||||
.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) {
|
||||
console.log("Not result.stream");
|
||||
@@ -220,9 +219,11 @@ async function checkScheduledSessions() {
|
||||
.json();
|
||||
console.log("result2: ", result2);
|
||||
}
|
||||
else if ((0, date_fns_1.isAfter)(new Date(), (0, date_fns_1.parseISO)(session.endAt))) {
|
||||
else if ((0, date_fns_1.isAfter)(new Date(), new Date(session.endAt))) {
|
||||
const result = await got_cjs_1.default
|
||||
.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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user