This commit is contained in:
2025-06-03 14:19:34 +05:00
parent c3b9a2e228
commit 1eb48c4299
3 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -2,4 +2,4 @@ PORT=3001
DB_URL=postgres://postgres:v1sq3vD5faXL@194.26.138.94:5432/mate
HMAC_SECRET=9a9ccda5db157ccfd04b4094264c55f58097f85d1fd6c22fbab0a86680dd3efd
API_URL=http://localhost:3000
COMPANY_ID=56e69b37-15e6-4de4-b953-e77435a09a06
COMPANY_ID=2a4f54db-7a1f-42c2-a965-3b185d92b063
+3
View File
@@ -19,6 +19,9 @@ export const serversTable = pgTable("servers", {
.notNull()
.defaultNow()
.$onUpdate(() => new Date()),
status: varchar("status", { enum: ["online", "offline"] })
.notNull()
.default("online"),
});
export const serversRelations = relations(serversTable, ({ one, many }) => ({
+13 -1
View File
@@ -218,7 +218,19 @@ if (!serverInfo) {
process.exit(1);
}
cron.schedule("* * * * * *", scheduleSession);
async function updateStatus() {
try {
await db
.update(serversTable)
.set({ status: "online" })
.where(eq(serversTable.id, serverInfo!.id));
} catch (error) {
console.log("Error updating status", error);
}
}
cron.schedule("*/5 * * * * *", scheduleSession);
cron.schedule("*/10 * * * * *", updateStatus);
serve({
port: 3001,