feat(scheduler): automatisations planifiées (cron) — tâche 5

- table schedules (migration 0007) + service scheduler (croner) : CRUD,
  runSchedule avec scope (all/liste), pool de concurrence et verrou par machine,
  mapping actions → refresh/metrics/docker_scan ; reloadSchedules au boot
- worker = reloadSchedules (remplace le refresh 30 min en dur)
- routes /api/schedules (CRUD + :id/run) ; cron invalide rejeté (validation croner)
- UI Paramètres : onglet « Automatisations » (liste, activer/lancer/supprimer, création)

tsc 0 · 113 tests · build OK · boot OK (migration 0007, CRUD vérifié).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-06 19:25:44 +02:00
parent bdbe7af55c
commit ff9cfaa9e1
11 changed files with 2796 additions and 18 deletions
@@ -0,0 +1,15 @@
CREATE TABLE `schedules` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`enabled` integer DEFAULT 1 NOT NULL,
`cron` text NOT NULL,
`timezone` text,
`scope_json` text NOT NULL,
`actions_json` text NOT NULL,
`concurrency` integer DEFAULT 2 NOT NULL,
`notify_on_json` text,
`last_run_at` text,
`last_status` text,
`created_at` text NOT NULL,
`updated_at` text NOT NULL
);
File diff suppressed because it is too large Load Diff
+7
View File
@@ -50,6 +50,13 @@
"when": 1780724800966,
"tag": "0006_many_northstar",
"breakpoints": true
},
{
"idx": 7,
"version": "6",
"when": 1780766513336,
"tag": "0007_bizarre_doctor_faustus",
"breakpoints": true
}
]
}
+17
View File
@@ -319,3 +319,20 @@ export const appSettings = sqliteTable("app_settings", {
value: text("value"),
updatedAt: text("updated_at").notNull(),
});
// Automatisations planifiées (cron) : analyse/metrics/scan sur un périmètre de machines.
export const schedules = sqliteTable("schedules", {
id: text("id").primaryKey(),
name: text("name").notNull(),
enabled: integer("enabled").notNull().default(1),
cron: text("cron").notNull(),
timezone: text("timezone"),
scopeJson: text("scope_json").notNull(), // {"machineIds":"all"|string[]}
actionsJson: text("actions_json").notNull(), // ["apt_update_analyze","machine_metrics_simple",...]
concurrency: integer("concurrency").notNull().default(2),
notifyOnJson: text("notify_on_json"),
lastRunAt: text("last_run_at"),
lastStatus: text("last_status"),
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull(),
});