Restart a server after its updates, and check that it came back

An update run can name a second Semaphore playbook that restarts the server
once the updates are in and it says a restart is due. The run keeps the
maintenance window up, follows the restart, waits for the server to report
again and checks from its uptime (or its restart flag clearing) that it did
start again. A server that only needs a restart has a Restart button on the
Updates page, and a patch plan can carry the restart playbook too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-10 23:45:52 +01:00
1 parent 97df28c6dc
commit e4f3a54189
19 files changed
+10275 -87

No files matched your search

+11
View File
@@ -36,7 +36,12 @@ const planSchema = z
onlyWithUpdates: z.boolean().default(true),
silenceDependents: z.boolean().default(true),
windowMinutes: z.number().int().min(15).max(480).default(90),
// A playbook that restarts a server that says a restart is due after its updates (all three or none).
restartProjectId: z.number().int().positive().nullable().default(null),
restartTemplateId: z.number().int().positive().nullable().default(null),
restartTemplateName: z.string().trim().min(1).max(200).nullable().default(null),
})
.refine((d) => (d.restartProjectId === null) === (d.restartTemplateId === null) && (d.restartTemplateId === null) === (d.restartTemplateName === null), { message: "The restart playbook needs its project, its template and its name — or none of them.", path: ["restartTemplateId"] })
.refine((d) => isValidTimeZone(d.timezone), { message: "That isn't a time zone the system knows (use a name like Europe/Stockholm).", path: ["timezone"] })
.refine((d) => d.tags.length > 0 || d.serverIds.length > 0, { message: "Choose which servers: give a tag, or name at least one server.", path: ["tags"] });
@@ -58,6 +63,9 @@ function valuesOf(d: z.infer<typeof planSchema>) {
onlyWithUpdates: d.onlyWithUpdates,
silenceDependents: d.silenceDependents,
windowMinutes: d.windowMinutes,
restartProjectId: d.restartProjectId,
restartTemplateId: d.restartTemplateId,
restartTemplateName: d.restartTemplateName,
};
}
@@ -96,6 +104,9 @@ async function shapePlan(p: PlanRow, all: { id: number; name: string; tags: stri
onlyWithUpdates: p.onlyWithUpdates,
silenceDependents: p.silenceDependents,
windowMinutes: p.windowMinutes,
restartProjectId: p.restartProjectId,
restartTemplateId: p.restartTemplateId,
restartTemplateName: p.restartTemplateName,
createdBy: p.createdBy,
servers: covered,
next: next.map((o) => o.start.toISOString()),