Builded new structure.

Now with remote setup and management Server
more than one Node can be connected
added user auth
This commit is contained in:
Philipp committed 2026-05-21 09:51:07 +02:00
1 parent 4c98d14352
commit aae54167a1
25 files changed
+1942 -52

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { agentRequest } from './agentClient.js';
import { listDueSchedules, markScheduleRun, nextRunFrom } from './store.js';
let timer = null;
export function startScheduler() {
if (timer) return;
timer = setInterval(runDueSchedules, 30 * 1000);
timer.unref?.();
runDueSchedules();
}
async function runDueSchedules() {
const now = new Date();
const schedules = listDueSchedules(now);
for (const schedule of schedules) {
try {
await agentRequest({
id: schedule.node_id,
baseUrl: schedule.base_url,
token: schedule.token,
}, `/backup/${encodeURIComponent(schedule.vm_name)}`, { method: 'POST' });
markScheduleRun(schedule.id, {
lastRunAt: now.toISOString(),
lastError: '',
nextRunAt: nextRunFrom(now, schedule.interval_hours, schedule.time_of_day),
});
} catch (error) {
markScheduleRun(schedule.id, {
lastRunAt: schedule.last_run_at,
lastError: String(error.message || error),
nextRunAt: new Date(now.getTime() + 5 * 60 * 1000).toISOString(),
});
}
}
}