restart

package
v0.82.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package restart owns how a running lich ends. The backend outlives its window; it ends only when stopped, by `lich quit`, a signal, or a restart: a detached successor is started and this process is stopped, freeing the pinned listener port for the successor to bind. The restart is what the POST /restart endpoint drives after install.sh replaces the binary on disk.

Index

Constants

View Source
const NativeBinary = "lich-native"

NativeBinary is the native window's executable, shipped beside lich's.

View Source
const NativeEnv = "LICH_NATIVE"

NativeEnv pins the native window to launch, by path. `go run` and a native build of one's own have no lich-native beside the lich binary.

View Source
const NoWindowArg = "--no-window"

NoWindowArg starts lich without its window.

View Source
const WaitEnv = "LICH_RESTART_WAIT"

WaitEnv marks a lich process spawned to succeed a restarting one. The listener bind path retries while this is set, because the outgoing process still holds the pinned port for a moment (see internal/terminal transport).

Variables

This section is empty.

Functions

func Companion added in v0.73.0

func Companion(env func(string) string, envName, binary, howToBuild string) (string, error)

Companion is the executable pinned by envName, else binary beside this lich binary; howToBuild finishes the sentence a missing one is reported with.

func NativeExecutable added in v0.73.0

func NativeExecutable(env func(string) string) (string, error)

NativeExecutable is the native window's binary: the one NativeEnv pins, else lich-native beside this lich binary. A missing one is an error that says how to get one.

func StartDetached

func StartDetached(exe string, env, args []string) error

StartDetached launches exe detached, so it outlives this process. stdio is left nil: the successor logs to its own file (main's logging.Init), like any lich launch.

func StartNative

func StartNative(exe string, env []string, logDir string) (*exec.Cmd, error)

StartNative launches the native window exe detached, its stdout and stderr appended to the native log under logDir (logging.OpenNative): detached, it has no terminal, and what it prints would otherwise go nowhere.

func WatchNative

func WatchNative(cmd *exec.Cmd)

WatchNative waits for the native window cmd, already started, to exit and logs how it ended, an exit code or the signal that killed it, with the last memory reading taken while it ran (Linux only). Waiting also reaps it: an exited window no one waits on stays a zombie under the backend.

func WithoutMarker

func WithoutMarker(env []string) []string

WithoutMarker is env minus the wait marker, on a fresh slice. The marker is for this process's own startup alone: what it spawns must not read as a restart successor, or a lich launched from one of its sessions never looks for the running one and dies on the busy port.

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator ends this lich: on its own (Quit), or after launching a detached successor (Do, Install), so this process unwinds, exits, and frees the port.

func New

func New(exePath string, env []string) *Coordinator

New returns a coordinator that relaunches exePath with env (plus the wait marker). env should be the current process environment so the successor pins the same listener port.

func (*Coordinator) Do

func (c *Coordinator) Do() error

Do launches the successor and stops this lich. Order matters: the successor starts first and blocks retrying the pinned port; then this process exits, and the freed port lets the successor bind. The open window closes with this lich rather than moving onto the successor: a restart follows an update, and the window still running is the old lich-native, whose calls the new backend may no longer take. The successor opens a window from the binary now on disk, and only where one was open.

func (*Coordinator) Install

func (c *Coordinator) Install(installer string) error

Install hands replacement and relaunch to Inno Setup. It waits for this PID to exit before touching files, so main's defers finish first. The window closes with this lich: the installer replaces lich-native.exe too, which Windows will not overwrite while it runs, and the lich it launches again opens a window of its own.

func (*Coordinator) Quit

func (c *Coordinator) Quit() error

Quit ends this lich: every session goes with it, and nothing is launched in its place.

func (*Coordinator) SetStop

func (c *Coordinator) SetStop(stop func())

SetStop supplies the clean exit: stop makes main unwind its defers and return. Called once lich is serving; a restart before that only spawns the successor.

func (*Coordinator) SetWindowOpen

func (c *Coordinator) SetWindowOpen(open func() bool)

SetWindowOpen supplies whether a native window is attached, which decides whether a successor opens one.

Jump to

Keyboard shortcuts

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