update

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package update replaces the running Zelie with a signed release. The core fetches and checks the release; a short-lived systemd unit, run from the binary being replaced, restarts the services and puts the old binary back if the new one does not come up.

Index

Constants

View Source
const (
	Old       = install.Binary + ".old"
	StateFile = "/var/lib/zelie/update.json"
	// Unit is the transient systemd unit that finishes an update. Its
	// fixed name also keeps two updates from running at once.
	Unit = "zelie-update"
	// HealthTimeout is how long the new version has to come up.
	HealthTimeout = 90 * time.Second
)

The binary being replaced is kept next to the new one until the next update, for the rollback and for anyone who wants to go back by hand.

View Source
const Repo = "Caria-Core/zelie"

Repo is where releases are published.

Variables

This section is empty.

Functions

func Newer

func Newer(a, b string) bool

Newer reports whether version a comes after b. A build that is not a release, such as "dev", is never older than anything: it cannot be told what it would be updated to.

func ParseKey

func ParseKey(data []byte) (ed25519.PublicKey, error)

ParseKey reads an Ed25519 public key in PEM, as openssl writes it.

func Place

func Place(root string, bin []byte) error

Place puts bin where the services run from, keeping the current binary as Old. Root is prepended to the paths; empty on a server.

func Started

func Started(root, from, to string, now time.Time) error

Started records that an update is under way, before the unit runs.

func Valid

func Valid(v string) bool

Valid reports whether v is a release version such as v1.2.3.

Types

type Fetcher

type Fetcher struct {
	Client *http.Client
	// Base is where release files are, with the version appended; tests
	// point it at a local server.
	Base string
	// Key replaces the embedded public key in tests.
	Key ed25519.PublicKey
}

Fetcher downloads releases.

func (*Fetcher) Binary

func (f *Fetcher) Binary(ctx context.Context, version, arch string) ([]byte, error)

Binary downloads the release's binary for arch and returns it once its checksum matches the signed list.

type Finisher

type Finisher struct {
	Root string
	Exec func(ctx context.Context, name string, args ...string) (string, error)
	// Healthy reports whether every service answers with version.
	Healthy func(ctx context.Context, version string) error
	Timeout time.Duration
	Now     func() time.Time
}

Finisher restarts the services on the new binary and checks that they come up. It runs from Old, so a new binary that does not even start cannot keep the old one from coming back.

func (*Finisher) Run

func (f *Finisher) Run(ctx context.Context, from, to string) Result

Run finishes the update from one version to another and records how it went.

type Result

type Result struct {
	From    string    `json:"from"`
	To      string    `json:"to"`
	Running bool      `json:"running,omitempty"`
	OK      bool      `json:"ok"`
	Error   string    `json:"error,omitempty"`
	At      time.Time `json:"at"`
}

Result is the outcome of the last update, as the panel shows it.

func Last

func Last(root string) (Result, error)

Last reads the outcome of the last update, if there was one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL