service

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: EUPL-1.2 Imports: 20 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// DefaultAPIAddr is the default HTTP listen address for the build API.
	DefaultAPIAddr = "127.0.0.1:9101"
	// DefaultHealthAddr is the default health probe address for daemon mode.
	DefaultHealthAddr = "127.0.0.1:9102"
	// DefaultWatchInterval is the file polling interval for auto-rebuilds.
	DefaultWatchInterval = 2 * time.Second
	// DefaultScheduleInterval is the cadence for periodic daemon jobs.
	DefaultScheduleInterval = time.Minute
)

Variables

This section is empty.

Functions

func Export

func Export(cfg Config, format string) core.Result

Export renders a native service definition for cfg.

Example

--- v0.9.0 generated usage examples ---

_ = Export(Config{}, "tar.gz")
core.Println("Export")
Output:
Export

func ResolveConfig

func ResolveConfig(projectDir string) core.Result

ResolveConfig loads service defaults for the project in projectDir.

Example

--- v0.9.0 generated usage examples ---

_ = ResolveConfig(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("ResolveConfig")
Output:
ResolveConfig

func ResolveNativeFormat

func ResolveNativeFormat(format string) core.Result

ResolveNativeFormat maps an explicit format or the current platform to a native service type.

Example
_ = ResolveNativeFormat("tar.gz")
core.Println("ResolveNativeFormat")
Output:
ResolveNativeFormat

func Run

func Run(ctx context.Context, cfg Config) core.Result

Run starts the background daemon for cfg until ctx is cancelled.

Example

--- v0.9.0 generated usage examples ---

_ = Run
core.Println("Run")
Output:
Run

Types

type Config

type Config struct {
	Name             string
	DisplayName      string
	Description      string
	ProjectDir       string
	WorkingDirectory string
	Executable       string
	Arguments        []string
	Environment      map[string]string
	PIDFile          string
	APIAddr          string
	HealthAddr       string
	WatchPaths       []string
	WatchInterval    time.Duration
	ScheduleInterval time.Duration
	AutoRebuild      bool
}

Config describes the installed background service and daemon runtime.

func DefaultConfig

func DefaultConfig(projectDir string) Config

DefaultConfig returns the default daemon and service manager settings.

Example
_ = DefaultConfig(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("DefaultConfig")
Output:
DefaultConfig

func (Config) Normalized

func (cfg Config) Normalized() Config

Normalized returns a copy of cfg with defaults, environment, and arguments applied.

Example
subject := Config{}
_ = subject.Normalized()
core.Println("Config_Normalized")
Output:
Config_Normalized

type ExportedConfig

type ExportedConfig struct {
	Format   NativeFormat
	Filename string
	Content  string
}

ExportedConfig is a generated native service definition.

type Manager

type Manager interface {
	Install(cfg Config) core.Result
	Start(cfg Config) core.Result
	Stop(cfg Config) core.Result
	Uninstall(cfg Config) core.Result
}

Manager wraps OS service manager operations.

func NewManager

func NewManager() Manager

NewManager returns the default OS service manager implementation.

Example

--- v0.9.0 generated usage examples ---

_ = NewManager()
core.Println("NewManager")
Output:
NewManager

type NativeFormat

type NativeFormat string

NativeFormat identifies the native service definition to generate.

const (
	NativeFormatSystemd NativeFormat = "systemd"
	NativeFormatLaunchd NativeFormat = "launchd"
	NativeFormatWindows NativeFormat = "windows"
)

type OSManager

type OSManager struct{}

OSManager uses github.com/kardianos/service to control native services.

func (*OSManager) Install

func (m *OSManager) Install(cfg Config) core.Result
Example
subject := &OSManager{}
_ = subject.Install(Config{})
core.Println("OSManager_Install")
Output:
OSManager_Install

func (*OSManager) Start

func (m *OSManager) Start(cfg Config) core.Result
Example
subject := &OSManager{}
_ = subject.Start(Config{})
core.Println("OSManager_Start")
Output:
OSManager_Start

func (*OSManager) Stop

func (m *OSManager) Stop(cfg Config) core.Result
Example
subject := &OSManager{}
_ = subject.Stop(Config{})
core.Println("OSManager_Stop")
Output:
OSManager_Stop

func (*OSManager) Uninstall

func (m *OSManager) Uninstall(cfg Config) core.Result
Example
subject := &OSManager{}
_ = subject.Uninstall(Config{})
core.Println("OSManager_Uninstall")
Output:
OSManager_Uninstall

Jump to

Keyboard shortcuts

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