Skip to content

wwhai/micro-upgrader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SelfUpdate (Go)

A lightweight self-upgrading component for Go CLI/daemon apps.

Features

  • Single binary supports self-upgrade
  • Version check from HTTP (v-x.y.z)
  • Locks to avoid systemd/supervisor restart conflict
  • Configurable executable path and URLs
  • Easy to import and use

Usage

up := selfupdate.New(selfupdate.Config{
	Version:        "v-1.0.0",
	CheckURL:       "http://localhost:8080/version.txt",
	UpgradeURL:     "http://localhost:8080/myapp",
	ExecutablePath: "/usr/local/bin/myapp",
	LockFile:       "/tmp/myapp.lock",
	Println:        fmt.Println,
})
up.MaybeUpgrade()

Example

go build -o myapp main.go
cp./myapp /usr/local/bin/myapp
cp./system/myapp.service /etc/systemd/system/
systemctl daemon-reexec
systemctl enable --now myapp.service

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages