base

package
v0.0.0-...-de7d1e5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseService

type BaseService struct {
	// contains filtered or unexported fields
}

func NewBaseService

func NewBaseService(name string, ctx context.Context, opts ServiceOptions) *BaseService

NewBaseService constructs a BaseService with the given name, parent context, and options.

func (*BaseService) AddLogHandler

func (bs *BaseService) AddLogHandler(h ServiceLogHandler)

AddLogHandler registers a log handler callback that is called for every line of output produced by the process.

func (*BaseService) IsInstalled

func (bs *BaseService) IsInstalled() bool

IsInstalled returns true if the service is present on the system.

func (*BaseService) IsReady

func (bs *BaseService) IsReady() bool

IsReady returns true if the service is fully operational.

func (*BaseService) IsRunning

func (bs *BaseService) IsRunning() bool

IsRunning returns true if the service's process is currently alive at the OS level.

func (*BaseService) Logger

func (bs *BaseService) Logger() *dslogger.Logger

Logger returns the service's logger.

func (*BaseService) Name

func (bs *BaseService) Name() string

Name returns the service's name.

func (*BaseService) Options

func (bs *BaseService) Options() ServiceOptions

Options returns a copy of the current ServiceOptions.

func (*BaseService) Restart

func (bs *BaseService) Restart()

Restart stops the process and starts it again with the same arguments.

func (*BaseService) SetOptions

func (bs *BaseService) SetOptions(opts ServiceOptions) error

SetOptions replaces the service's options.

func (*BaseService) SetPostRestartHook

func (bs *BaseService) SetPostRestartHook(fn func())

SetPostRestartHook registers a function to be called after the process has been successfully restarted in a Restart cycle. Only one hook is suported.

func (*BaseService) SetPreRestartHook

func (bs *BaseService) SetPreRestartHook(fn func())

SetPreRestartHook registers a function to be called before the process is stopped during a Restart cycle. Only one hook is supported.

func (*BaseService) Start

func (bs *BaseService) Start(args []string) error

Start initiates the service's process and manages the start/stop lifecycle.

func (*BaseService) Stop

func (bs *BaseService) Stop() error

Stop attempts to stop the service's process gracefully, then forcefully if necessary.

func (*BaseService) Wait

func (bs *BaseService) Wait() error

Wait waits for the process to exit and returns any execution error.

type ServiceLogHandler

type ServiceLogHandler func(line string) (shouldRestart bool)

ServiceLogHandler is a function that receives each log line from the process. Return true to signal that the service should be restarted.

type ServiceOptions

type ServiceOptions struct {
	RootDirectory    string
	WorkingDirectory string
	AutoRestart      bool
	MaxRestarts      int
	RestartDelay     time.Duration
	ShutdownTimeout  time.Duration
	KillTimeout      time.Duration
}

Jump to

Keyboard shortcuts

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