servicehost

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package servicehost defines the native service-manager recovery policy.

Index

Constants

View Source
const (

	// FailureExitCode signals an unexpected process failure to service managers.
	FailureExitCode = 1
	// FailureWindow bounds the period used to detect a crash loop.
	FailureWindow = 10 * time.Minute
	// CrashLoopFailureCount is the first failure count that exhausts recovery.
	CrashLoopFailureCount = maxFailureExits + 1
)
View Source
const (
	// StopTimeout leaves the service manager time to finish process teardown.
	StopTimeout = 15 * time.Second
)

Variables

This section is empty.

Functions

func ClearFailures

func ClearFailures(configPath string) error

ClearFailures resets the crash-loop budget after an intentional stop.

func ConfigureRecovery

func ConfigureRecovery(string) error

ConfigureRecovery is encoded in the installed systemd unit.

func FailureCount

func FailureCount(configPath string, now time.Time) (int, error)

FailureCount returns fatal runs still inside the recovery window.

func Options

func Options() service.KeyValue

Options returns the kardianos options for the current platform.

func OptionsFor

func OptionsFor(goos string) service.KeyValue

OptionsFor returns the native recovery configuration for goos.

func RecordFailure

func RecordFailure(configPath string, now time.Time, summary string) error

RecordFailure persists a fatal run for doctor diagnostics.

func ResetRecovery

func ResetRecovery(name, platform string) error

ResetRecovery clears systemd's failed state and start-rate counter.

func Status

func Status(_ string, svc service.Service) (service.Status, error)

Status delegates to the native kardianos implementation off Windows.

func WindowsRestartDelays

func WindowsRestartDelays() []time.Duration

WindowsRestartDelays returns the finite SCM recovery schedule.

Types

type FailureStatus

type FailureStatus struct {
	Count       int
	LastFailure time.Time
	LastError   string
}

FailureStatus describes recent service recovery activity.

func ReadFailureStatus

func ReadFailureStatus(configPath string, now time.Time) (FailureStatus, error)

ReadFailureStatus returns recent retry count and the sanitized last failure.

Jump to

Keyboard shortcuts

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