- internal/config: .env-style config file (gpu-turnstile.env next to the exe, -config flag or GPU_TURNSTILE_CONFIG); process env overrides file. - internal/service: Windows service via golang.org/x/sys/windows/svc — graceful SCM stop, 'service install/remove' commands, restart-on-failure recovery (also applies staged updates). First external dependency, Windows-only; Linux/Docker build unaffected (go.mod stays at 1.23). - internal/update: polls the Gitea releases API, verifies the Ed25519 signature of the downloaded binary against an embedded public key (openssl-signed by CI), swaps it in next to the running exe, and once the GPU lock is idle exits with code 3 so service recovery restarts onto the new version. Dev builds and empty pubkey never update. - CI: tag builds additionally produce gpu-turnstile.exe + .sig + .sha256 attached to a Gitea release. - LOG_FILE env var so the service has somewhere to log.
36 lines
986 B
Go
36 lines
986 B
Go
//go:build !windows
|
|
|
|
// Package service provides the non-Windows stubs for the Windows service
|
|
// integration. Run falls back to plain signal handling; install/remove
|
|
// are unsupported.
|
|
package service
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
// Name matches the Windows service name.
|
|
const Name = "gpu-turnstile"
|
|
|
|
var errUnsupported = errors.New("service management is only supported on Windows")
|
|
|
|
// IsService is always false on non-Windows platforms.
|
|
func IsService() bool { return false }
|
|
|
|
// Run executes run with SIGINT/SIGTERM cancellation, mirroring the
|
|
// interactive behavior.
|
|
func Run(run func(ctx context.Context) error) error {
|
|
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
defer stop()
|
|
return run(ctx)
|
|
}
|
|
|
|
// Install is unsupported on non-Windows platforms.
|
|
func Install(string) error { return errUnsupported }
|
|
|
|
// Remove is unsupported on non-Windows platforms.
|
|
func Remove() error { return errUnsupported }
|