feat(update): stream live progress and roll back failed updates automatically
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.
This commit is contained in:
1 parent
a24f6fa8b0
commit
7c409aadb5
20 files changed
+1133
-57
No files matched your search
@@ -815,6 +815,18 @@ func releaseAnnouncementStatePath(workDir, identity string) string {
|
||||
)
|
||||
}
|
||||
|
||||
// updateReportPath is where the update watchdog leaves the phase-2 outcome
|
||||
// of an update for this identity to relay on its next launch. Hashed the
|
||||
// same way as releaseAnnouncementStatePath so multiple identities sharing
|
||||
// one daemon (see docs/architecture/identity.md) never collide.
|
||||
func updateReportPath(workDir, identity string) string {
|
||||
identityHash := sha256.Sum256([]byte(identity))
|
||||
return filepath.Join(
|
||||
workDir,
|
||||
fmt.Sprintf("update-report-%x.json", identityHash[:8]),
|
||||
)
|
||||
}
|
||||
|
||||
// safePluginInfo calls Name() and Version() on a plugin, recovering from
|
||||
// panics. A panicking plugin must not crash the daemon at startup.
|
||||
func safePluginInfo(p plugin.Plugin) (name, version string) {
|
||||
|
||||
@@ -95,6 +95,7 @@ func setupTelegramGateway(ctx context.Context, s telegramSetup) (start func(), o
|
||||
{ID: "runtime", Label: "THE RUNTIME", Version: runtimeVersion, ChangelogPath: packagedRuntimeChangelogPath},
|
||||
},
|
||||
}
|
||||
tg.UpdateReportPath = updateReportPath(cfg.WorkDir, cfg.BotUser)
|
||||
tg.Reload = makeTelegramReload(s)
|
||||
|
||||
sessionStore := s.SessionStore
|
||||
|
||||
Reference in new issue
Block a user