Documentation ¶
Index ¶
- func SetLogger(customLogger Logger)
- type Logger
- type ServiceCommand
- type ServiceDoesNotExistError
- type ServiceStatus
- type SystemService
- func (s *SystemService) Exists() bool
- func (s *SystemService) Install(start bool) error
- func (s *SystemService) Restart() error
- func (s *SystemService) Run() error
- func (s *SystemService) Running() (bool, error)
- func (s *SystemService) Start() error
- func (s *SystemService) Status() (status *ServiceStatus, err error)
- func (s *SystemService) Stop() error
- func (s *SystemService) Uninstall() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface { Log(v ...interface{}) Logf(format string, v ...interface{}) }
Logger implements a basic, overridable logging interface
type ServiceCommand ¶
type ServiceCommand struct { // The human-friendly name of your service. Note: best to not include // spaces in the name. Name string // The label to use to identify the service. This must be unique // and should not include spaces. Label string // The name of the program to run Program string // The arguments to pass to the command. Optional. Args []string // The description of your service. Optional. Description string // The URL to your service documentation. Optional. Documentation string // Whether or not to turn on debug behavior Debug bool }
ServiceCommand represents the command the system service should run
func (*ServiceCommand) String ¶
func (c *ServiceCommand) String() string
type ServiceDoesNotExistError ¶
type ServiceDoesNotExistError struct {
// contains filtered or unexported fields
}
ServiceDoesNotExistError is an error return if a given service does not exist on the system. This is usually returned if the user attempts to manage a service not yet configured on the system.
func (*ServiceDoesNotExistError) Error ¶
func (e *ServiceDoesNotExistError) Error() string
Error implements the errors.Error interface
type ServiceStatus ¶
ServiceStatus is a generic representation of the service running on the system
type SystemService ¶
type SystemService struct {
Command ServiceCommand
}
SystemService represents a generic system service configuration
func New ¶
func New(cmd ServiceCommand) SystemService
New creates a new system service manager instance.
func (*SystemService) Exists ¶
func (s *SystemService) Exists() bool
Exists returns whether or not the unit file eixts
func (*SystemService) Install ¶
func (s *SystemService) Install(start bool) error
Install the system service. If start is passed, also starts the service.
func (*SystemService) Restart ¶
func (s *SystemService) Restart() error
Restart attempts to stop the service if running then starts it again
func (*SystemService) Run ¶
func (s *SystemService) Run() error
Run is a no-op on Linux based systems
func (*SystemService) Running ¶
func (s *SystemService) Running() (bool, error)
Running indicates if the service is active and running
func (*SystemService) Start ¶
func (s *SystemService) Start() error
Start the system service if it is installed
func (*SystemService) Status ¶
func (s *SystemService) Status() (status *ServiceStatus, err error)
Status returns whether or not the system service is running
func (*SystemService) Stop ¶
func (s *SystemService) Stop() error
Stop stops the system service by unloading the unit file
func (*SystemService) Uninstall ¶
func (s *SystemService) Uninstall() error
Uninstall the system service by first stopping it then removing the unit file.