Documentation
¶
Overview ¶
Package ossvc contains abstractions and utilities for platform-independent service management.
TODO(e.burkov): Add tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureServiceOptions ¶ added in v0.107.72
ConfigureServiceOptions defines additional settings of the service configuration. conf must not be nil.
TODO(e.burkov): Use [timeutil.Clock].
Types ¶
type Action ¶
type Action interface {
// Name returns the name of the action.
Name() (name ActionName)
// contains filtered or unexported methods
}
Action is the interface for actions that can be performed by Manager.
type ActionInstall ¶
type ActionInstall struct {
ServiceName ServiceName
DisplayName string
Description string
WorkingDirectory string
Version string
Arguments []string
}
ActionInstall is the implementation of the Action interface.
func (*ActionInstall) Name ¶
func (a *ActionInstall) Name() (name ActionName)
Name implements the Action interface for *ActionInstall.
type ActionName ¶
type ActionName string
ActionName is the type for actions' names. It has the following valid values:
const ( ActionNameInstall ActionName = "install" ActionNameRestart ActionName = "restart" ActionNameStart ActionName = "start" ActionNameStop ActionName = "stop" ActionNameUninstall ActionName = "uninstall" )
type ActionRestart ¶ added in v0.107.72
type ActionRestart struct {
ServiceName ServiceName
}
ActionRestart is the implementation of the Action interface.
func (*ActionRestart) Name ¶ added in v0.107.72
func (a *ActionRestart) Name() (name ActionName)
Name implements the Action interface for *ActionRestart.
type ActionStart ¶
type ActionStart struct {
ServiceName ServiceName
}
ActionStart is the implementation of the Action interface.
func (*ActionStart) Name ¶
func (a *ActionStart) Name() (name ActionName)
Name implements the Action interface for *ActionStart.
type ActionStop ¶
type ActionStop struct {
ServiceName ServiceName
}
ActionStop is the implementation of the Action interface.
func (*ActionStop) Name ¶
func (a *ActionStop) Name() (name ActionName)
Name implements the Action interface for *ActionStop.
type ActionUninstall ¶
type ActionUninstall struct {
ServiceName ServiceName
}
ActionUninstall is the implementation of the Action interface.
func (*ActionUninstall) Name ¶
func (a *ActionUninstall) Name() (name ActionName)
Name implements the Action interface for *ActionUninstall.
type EmptyManager ¶
type EmptyManager struct{}
EmptyManager is an empty implementation of Manager that does nothing.
func (EmptyManager) Perform ¶
func (EmptyManager) Perform(_ context.Context, _ Action) (err error)
Perform implements the Manager interface for EmptyManager.
func (EmptyManager) Status ¶
func (EmptyManager) Status(_ context.Context, _ ServiceName) (status Status, err error)
Status implements the Manager interface for EmptyManager.
type Manager ¶
type Manager interface {
// Perform performs the specified action.
Perform(ctx context.Context, action Action) (err error)
// Status returns the status of the service with the given name.
Status(ctx context.Context, name ServiceName) (status Status, err error)
}
Manager is the interface for communication with the OS service manager.
TODO(e.burkov): Move to golibs.
TODO(e.burkov): Use.
func NewManager ¶
func NewManager(ctx context.Context, conf *ManagerConfig) (mgr Manager, err error)
NewManager returns a new properly initialized Manager, appropriate for the current platform.
type ManagerConfig ¶
type ManagerConfig struct {
// Logger is the logger to use.
Logger *slog.Logger
// CommandConstructor is the constructor to use for creating commands.
CommandConstructor executil.CommandConstructor
}
ManagerConfig contains the configuration for Manager.
type ReloadManager ¶ added in v0.107.72
type ReloadManager interface {
Manager
// Reload reloads the service with the given name. As opposed to
// [ActionRestart], this method does not stop the service.
Reload(ctx context.Context, name ServiceName) (err error)
}
ReloadManager is the extension interface for Manager that provides an ability to reload a service.
type ServiceName ¶
type ServiceName string
ServiceName is the name of a service.
TODO(e.burkov): Validate for each platform.
type Status ¶
type Status string
Status represents the status of a service.
const ( // StatusNotInstalled means that the service is not installed. StatusNotInstalled Status = "not installed" // StatusStopped means that the service is stopped. StatusStopped Status = "stopped" // StatusRunning means that the service is running. StatusRunning Status = "running" // StatusRestartOnFail means that the service is restarting after failed // start. StatusRestartOnFail Status = "restart on fail" )