winsvc

package
v0.22.166 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package winsvc registers the clawtool daemon as a Windows Service so it survives logout and starts on boot — the missing piece of the Windows installer's "drop binary → register service → firewall" flow (PR-E stage 2).

On non-Windows platforms every operation returns ErrUnsupported; Linux keeps running the daemon as a detached process and macOS uses a LaunchAgent (handled elsewhere). The Windows Service Control Manager interaction lives in winsvc_windows.go behind a build tag; this file holds the platform-agnostic Config + validation so the argument-shaping logic is unit-testable on any OS.

Verification note: the SCM calls (create / start / delete / query) can only be exercised on Windows with Administrator rights — CI runs Linux + macOS, so those paths are cross-compile-checked but not runtime-tested here. The Config validation below is.

Index

Constants

View Source
const DefaultDisplayName = "clawtool daemon"

DefaultDisplayName is the services.msc label used when Config.DisplayName is empty.

View Source
const DefaultName = "clawtool"

DefaultName is the SCM service key clawtool registers under when Config.Name is empty.

Variables

View Source
var ErrUnsupported = errors.New("winsvc: Windows Service registration is only supported on Windows")

ErrUnsupported is returned by every operation on non-Windows platforms. Callers should treat it as "skip, not a failure" — the daemon's other lifecycle paths cover those OSes.

Functions

func Install

func Install(_ Config) error

Install is a no-op that reports the platform is unsupported.

func Remove

func Remove(_ string) error

Remove is a no-op that reports the platform is unsupported.

func Start

func Start(_ string) error

Start is a no-op that reports the platform is unsupported.

Types

type Config

type Config struct {
	// Name is the SCM service name (the key, no spaces). Defaults to
	// DefaultName when empty.
	Name string
	// DisplayName is the human-readable name shown in services.msc.
	DisplayName string
	// Description is the longer blurb shown in the service properties.
	Description string
	// BinPath is the absolute path to clawtool.exe.
	BinPath string
	// Args are the daemon launch arguments, e.g.
	// ["serve","--listen","127.0.0.1:52828","--no-auth","--mcp-http"].
	Args []string
	// AutoStart registers the service as start-on-boot (SERVICE_AUTO_
	// START) rather than manual.
	AutoStart bool
}

Config describes the clawtool daemon service to register.

type State

type State string

State is a coarse service lifecycle state, decoupled from the x/sys svc.State enum so callers (and the GUI's JSON wire) don't depend on the Windows-only package.

const (
	StateUnknown    State = "unknown"
	StateStopped    State = "stopped"
	StateStartTrig  State = "start_pending"
	StateRunning    State = "running"
	StateStopTrig   State = "stop_pending"
	StateNotPresent State = "not_present"
)

func Status

func Status(_ string) (State, error)

Status reports StateNotPresent on platforms without an SCM.

Jump to

Keyboard shortcuts

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