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 ¶
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. Going back by hand needs the panel's database from before the update as well, and that copy does not outlive the update.
const DBCopy = "/var/lib/zelie/panel.db.before-update"
The new version migrates the panel's database as soon as it starts, and a version that finds a schema newer than the one it knows refuses to open it. An update that goes back would then bring up a panel that cannot start. So the update keeps a copy of the database from before the new version ran and puts it back with the old binary. DBCopy is where it waits, out of the panel's own directory.
const Repo = "Caria-Core/zelie"
Repo is where releases are published.
Variables ¶
This section is empty.
Functions ¶
func Newer ¶
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 Place ¶
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 Revert ¶ added in v0.7.14
Revert puts Old back as the binary the services run from, for an update that did not come up or could not be started at all.
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.
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.
type Result ¶
type Result struct {
From string `json:"from"`
To string `json:"to"`
Running bool `json:"running,omitempty"`
OK bool `json:"ok"`
// Reason is why the update failed and Back what became of the old
// version, for the web interface to say in the user's language. Error
// is both in English, as earlier versions saved it.
Reason *msg.Msg `json:"reason,omitempty"`
Back *msg.Msg `json:"back,omitempty"`
Error string `json:"error,omitempty"`
At time.Time `json:"at"`
}
Result is the outcome of the last update, as the panel shows it.