Documentation
¶
Index ¶
- type BaseService
- func (bs *BaseService) AddLogHandler(h ServiceLogHandler)
- func (bs *BaseService) IsInstalled() bool
- func (bs *BaseService) IsReady() bool
- func (bs *BaseService) IsRunning() bool
- func (bs *BaseService) Logger() *dslogger.Logger
- func (bs *BaseService) Name() string
- func (bs *BaseService) Options() ServiceOptions
- func (bs *BaseService) Restart()
- func (bs *BaseService) SetOptions(opts ServiceOptions) error
- func (bs *BaseService) SetPostRestartHook(fn func())
- func (bs *BaseService) SetPreRestartHook(fn func())
- func (bs *BaseService) Start(args []string) error
- func (bs *BaseService) Stop() error
- func (bs *BaseService) Wait() error
- type ServiceLogHandler
- type ServiceOptions
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) 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 ¶
ServiceLogHandler is a function that receives each log line from the process. Return true to signal that the service should be restarted.