install

package
v0.34.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: GPL-3.0 Imports: 29 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

View Source
var BuildTarget string
View Source
var ErrRestartUnsupported = errors.New("a process not run as a Windows service cannot restart itself reliably")

ErrRestartUnsupported is returned by UpdateSelf where the calling process cannot restart itself reliably.

Functions

func CanRestartSelf added in v0.34.9

func CanRestartSelf() bool

CanRestartSelf reports whether the calling process can restart itself as a new version without its parent noticing. On Unix the process image is replaced in place. A Windows process has to be started anew; that is only reliable for a service, which the service manager restarts, while whatever started any other process would see it exit.

func ConfigureService added in v0.34.9

func ConfigureService(c *service.Config)

ConfigureService sets the platform specific settings of c.

func ControlService added in v0.34.8

func ControlService(s service.Service, name, action string) error

ControlService runs a service control action. SysV init systems are driven through the init script directly so BusyBox based systems such as OpenWrt work as well.

func CopyDir

func CopyDir(srcPath string, destPath string) error

CopyDir copies the files under srcPath into destPath, creating directories as needed.

func GeoDataVersion added in v0.34.9

func GeoDataVersion(ipPath string) string

GeoDataVersion returns the release the geodata files next to ipPath come from, "" when unknown.

func LatestVersion added in v0.34.9

func LatestVersion() string

LatestVersion returns the tag of the latest release as last queried, or "" before a query succeeded. A stale or missing tag is queried again in the background, every 6 hours, or 10 minutes after a failure.

func NPC added in v0.34.8

func NPC() (string, error)

NPC installs the npc executable and returns the path the service should run.

func NPS added in v0.34.8

func NPS() (string, error)

NPS installs the nps executable, web assets and, on a fresh install, the config directory. It returns the path the service should run.

func Relaunch added in v0.34.9

func Relaunch(exe string) error

Relaunch replaces the calling process, which does not run as a service, with exe run with the same arguments and environment. On Unix the process image is replaced in place. Windows has no such call: exe is started to wait for the caller to exit, and the caller exits.

func RemoveStaleExecutables added in v0.34.8

func RemoveStaleExecutables()

RemoveStaleExecutables deletes executables that an earlier update moved aside on Windows. They stay locked until the process running them exits, so failures are ignored and retried on the next start or update.

func RestartAfterUpdate added in v0.34.8

func RestartAfterUpdate(s service.Service, name string, replaced []string) error

RestartAfterUpdate restarts the service so it runs the replaced executables. Only an installed and running service is restarted; otherwise the new version takes effect on the next start. When the service is known to run an executable outside replaced it is left alone, since a restart would not pick up the update. A nil s means the service manager is unavailable.

func RestartSelf added in v0.34.9

func RestartSelf(exe string) error

RestartSelf makes the calling process continue as exe, the executable an update replaced, and returns only on failure, with one exception: a Windows service hands the restart to the service manager and returns at once, to be stopped by it shortly. On Unix the process image is replaced in place, which keeps its process ID, so a service manager supervising it does not see the restart; this holds in containers as well.

func SetGeoDataPaths added in v0.34.9

func SetGeoDataPaths(ipPath, sitePath string)

SetGeoDataPaths sets where nps keeps its geodata files, for update to refresh them from the release package.

func SyncGeoData added in v0.34.9

func SyncGeoData(srcConf, ipPath, sitePath string) error

SyncGeoData copies the geodata files of an unpacked release in srcConf to ipPath and sitePath when the release has newer ones than those in place, or when a file is missing. Newer files from UpdateGeoData are kept.

func UninstallService added in v0.34.9

func UninstallService(s service.Service, name string) error

UninstallService uninstalls s, the system service name. systemd refuses to disable a unit whose file is empty, and procd runs the init script, which an empty or foreign script fails; the files of the service are then deleted directly so that a later install does not find them in place.

func UpdateAvailable added in v0.34.9

func UpdateAvailable() bool

UpdateAvailable reports whether the latest release known is newer than this build.

func UpdateSelfNpc added in v0.34.9

func UpdateSelfNpc(name string) error

UpdateSelfNpc updates the running npc, installed as the system service name or not, to the latest release and restarts it as the new version. It returns nil without restarting when the running version is the latest; otherwise it returns only on failure, or at once for a Windows service, which the service manager then restarts.

func WaitForRelaunch added in v0.34.9

func WaitForRelaunch()

WaitForRelaunch waits, in a process started by Relaunch, until the process it replaces has exited and released what it held, such as its ports.

func WarnOldProcesses added in v0.34.9

func WarnOldProcesses(pids []int32)

WarnOldProcesses reports the processes among pids that still run, and so still run the version an update replaced.

Types

type GeoFile added in v0.34.9

type GeoFile struct {
	Name string
	Path string
}

GeoFile is one geodata file: its name in the release and its local path.

func GeoFiles added in v0.34.9

func GeoFiles(ipPath, sitePath string) []GeoFile

GeoFiles returns the geodata files kept at ipPath and sitePath.

type GeoUpdate added in v0.34.9

type GeoUpdate struct {
	// Version is the release the files now come from, "" when unknown.
	Version string
	// Updated lists the files that were replaced.
	Updated []string
}

GeoUpdate is the result of UpdateGeoData.

func UpdateGeoData added in v0.34.9

func UpdateGeoData(ipPath, sitePath string) (*GeoUpdate, error)

UpdateGeoData downloads the latest geoip.dat and geosite.dat to ipPath and sitePath. A file whose content already matches the release is left alone. Each file is checked against its SHA-256 digest and replaced atomically, so that a reader never sees a partial file.

type SelfUpdate added in v0.34.9

type SelfUpdate struct {
	// Version is the version updated to.
	Version string
	// contains filtered or unexported fields
}

SelfUpdate is an update of the running executable whose restart is still to come.

func UpdateSelfNps added in v0.34.9

func UpdateSelfNps(name string) (*SelfUpdate, error)

UpdateSelfNps updates the running nps, installed as the system service name or not, to the latest release, leaving the restart to the caller. A nil update with a nil error means the running version is the latest; an update with an error means the executables were replaced but the web assets were not, and the restart is still due.

func (*SelfUpdate) Restart added in v0.34.9

func (u *SelfUpdate) Restart() error

Restart makes the calling process continue as the new version; see RestartSelf.

type UpdateResult added in v0.34.9

type UpdateResult struct {
	// Version is the version updated to.
	Version string
	// Replaced are the executables replaced with the new version.
	Replaced []string
	// Running are the other processes that ran a replaced executable when it
	// was replaced; they keep running the old version until restarted.
	Running []int32
}

UpdateResult describes a completed update.

func UpdateNpc

func UpdateNpc(service string) (*UpdateResult, error)

UpdateNpc replaces the npc executables with the latest release. A nil result with a nil error means the running version is already the latest.

func UpdateNps

func UpdateNps(service string) (*UpdateResult, error)

UpdateNps replaces the nps executables with the latest release and then refreshes the web assets of the current run directory. A nil result with a nil error means the running version is already the latest.

Jump to

Keyboard shortcuts

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