GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - danilevy1212/self-updater: A cross-platform Go utility for running and securely updating a server at runtime, using a signed release manifest to enable minimal-downtime restarts.

BranchesTags
Open more actions menu

Latest commit

 

History

15 Commits
15 Commits

Folders and files

NameName
Last commit message
Last commit date
cmd
cmd
 
 
internal
internal
 
 
scripts
scripts
 
 
.envrc
.envrc
 
 
.gitignore
.gitignore
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
flake.lock
flake.lock
 
 
flake.nix
flake.nix
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 

Repository files navigation

Self-Updater

A Go-based self-updating server and launcher utility. The API server can update its binary at runtime using a signed release manifest.

Features

  • Self-updating server process with minimal downtime restart signals
  • Signed release manifest generation and verification
  • Multi-platform builds (Linux, macOS, Windows for amd64 and arm64)
  • Simple CLI tool for signing artifacts

Prerequisites

  • Go 1.24+
  • Git
  • (Optional) Nix: nix develop for a consistent development shell
  • (Optional) Direnv for automatic environment loading

Getting Started

Clone the repository:

git clone https://github.com/danilevy1212/self-updater.git
cd self-updater

Enter a development shell (requires Nix):

nix develop

Building

Use the Makefile to format, test, and build:

make all        # format, test, and build binaries
make build-api  # build only the API binaries

The binaries will be in the bin/ directory:

  • bin/api-linux-amd64
  • bin/api-windows-amd64.exe
  • bin/api-darwin-amd64
  • bin/api-linux-arm64
  • bin/api-darwin-arm64
  • bin/api-windows-arm64.exe

Configuration

The server can be configured via environment variables:

Variable Default Description
SERVER_PORT 3000 Port for the API server to listen
SERVER_IS_DEV false Enable development mode
UPDATER_IS_DEV false Enable updater development mode
UPDATER_CRON_SCHEDULE * * * * * Cron schedule for updates
UPDATER_RUN_AT_BOOT true Run updater at boot time
LAUNCHER_IS_DEV false Enable launcher development mode
LAUNCHER_SESSION_FOLDER update-session Folder in temporary storage for update sessions
ARCHIVER_REPO self-updater GitHub repository for the release manifest
ARCHIVER_OWNER your-org GitHub owner for the release manifest
ARCHIVER_BASE_URL https://github.com Base URL for the release manifest

Usage

Run the launcher

./bin/api-linux-amd64

Run the server stand alone

./bin/api-linux-amd64 --server --current-session-dir /tmp/update-session/<unique-id>
  • --server: run the API server and updater in the same process
  • --current-session-dir: directory used to store and swap binaries

Sign artifacts

Build the sign tool and use it to sign binaries or the manifest:

go run ./cmd/sign <private-key.pem> <file-to-sign>
# or, after building:
./bin/sign <private-key.pem> <file-to-sign>

Release

To generate or update the signed release manifest (internal/assets/release.json):

export SIGNING_KEY_PEM="$(cat path/to/private.pem)"
export PUBLIC_KEY_PEM="$(cat path/to/public.pem)"
export ARCHIVER_BASE_URL="https://github.com/your-org/self-updater/releases/download"
export ARCHIVER_OWNER="your-org"
export ARCHIVER_REPO="self-updater"
make release

Testing

make test

Design

The self-updater is designed to allow a server process to update itself with minimal downtime. It uses a signed manifest to verify the integrity of updates and supports multiple platforms.

When executed in it's default mode (launcher mode), the binary will create a temporary directory for the update session. It will copy the current binary to this directory and start it in server mode. The server will run the updater in a separate goroutine, which will periodically check for updates based on the configured cron schedule.

If an update is available, the updater will download the new binary, verify it using the signed manifest, and signal to the launcher to restart with the new binary. The launcher will then swap the old binary with the new one and restart the server process.

About

A cross-platform Go utility for running and securely updating a server at runtime, using a signed release manifest to enable minimal-downtime restarts.

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.