Windows: --install-service creates %ProgramFiles%\gpu-turnstile and %ProgramData%\gpu-turnstile, copies the exe and (if absent) the env file in, and registers the copy. Linux: binary goes to /var/lib/gpu-turnstile (not /usr/local/sbin: replacing a running binary needs directory write, which must not be granted on a shared system dir to a sandboxed service). --no-copy registers the current location as-is on both platforms.
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
//go:build !windows && !linux
|
|
|
|
// Package service provides the stubs for platforms without service
|
|
// integration (Windows uses the SCM, Linux uses systemd). 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 and Linux (systemd)")
|
|
|
|
// 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, non-Linux platforms.
|
|
func Install(string, bool) error { return errUnsupported }
|
|
|
|
// Remove is unsupported on non-Windows platforms.
|
|
func Remove() error { return errUnsupported }
|