The /update command went silent between "starting" and one final message, gave no version summary, and required manual intervention on failure. CommandInstaller now streams the installer script's stdout live instead of buffering it, and parses a structured result (previous/installed versions, per-component status) from a sentinel line. Because the reference install script hands the daemon restart off to a detached systemd unit specifically so restarting archied.service doesn't kill the process that requested the update, the outcome is reported in two phases: the synchronous build/install result comes back through Install() itself, and the post-restart health check/rollback outcome is written by a new watchdog script and relayed by whichever archied process boots next, via a small JSON handoff file cleared once relayed. Also fixes three defects an adversarial review pass found in the first draft: the caller's request/handler context was passed straight into the install child process, so a concurrent /restart or a browser disconnect could SIGKILL it mid binary-copy; Telegram and the web dashboard each tracked "install in progress" with their own private flag despite sharing one Service, allowing two installs to race the same .prev backups; and the watchdog reported rolled_back:true even when no backup existed to restore, which would have told an operator to stand down while the daemon was still broken. internal/webui gains an unauthenticated /healthz the watchdog polls after restarting archied.
38 lines
1.6 KiB
Go
38 lines
1.6 KiB
Go
package releaseupdate
|
|
|
|
// InstallMeta identifies who to notify once an installed update finishes
|
|
// restarting. The process that calls Install returns before the daemon
|
|
// actually restarts (the reference installer queues the restart through a
|
|
// detached unit so restarting archied.service doesn't kill the installer
|
|
// mid-run), so this identity has to survive the restart on disk -- see
|
|
// Report and WritePendingReport.
|
|
type InstallMeta struct {
|
|
Channel string
|
|
ChatID int64
|
|
ThreadID int
|
|
// ReportPath is where the installer's restart/health-check tooling
|
|
// should write the phase-2 Report once it knows the outcome -- see
|
|
// WritePendingReport. Empty means the deployment has no phase-2
|
|
// reporting configured (the caller only gets the synchronous Result).
|
|
ReportPath string
|
|
}
|
|
|
|
// ComponentResult reports what an installer actually did to one component.
|
|
type ComponentResult struct {
|
|
ID string `json:"id"`
|
|
Label string `json:"label"`
|
|
Status string `json:"status"` // "updated", "unchanged", or "failed"
|
|
}
|
|
|
|
// Result is the structured outcome of the synchronous phase of an install:
|
|
// fetch/build/install, before any restart happens. Previous and Installed
|
|
// map a component ID to its version. Field names are snake_case in JSON to
|
|
// match the install script's ARCHIE_UPDATE_RESULT sentinel line -- see
|
|
// command.go and scripts/archie-update-install.
|
|
type Result struct {
|
|
Previous map[string]string `json:"previous"`
|
|
Installed map[string]string `json:"installed"`
|
|
Components []ComponentResult `json:"components"`
|
|
RestartRequested bool `json:"restart_requested"`
|
|
}
|